Sorry, but I'm a newbie with Fortran.... so I don't get it why the following program continues to evaluate x as a single precision variable? Why are there non zero decimals?
Mark.
-----------------------------------------
program precision_test
implicit none
integer, parameter :: sgl = selected_real_kind(p=6)
integer, parameter :: dbl = selected_real_kind(p=15)
real (kind=dbl) :: x
x = dble(3.140000000000000)
write(*,*)'Single precision kind=', sgl
write(*,*)'Double precision kind=', dbl
write(*,*) 'precision of x=', precision(x)
write(*,*) 'x=',dble(x)
end program precision_test
------------------------------------------
The Output I get is:
Single precision kind=4
Double precision kind=8
Precision of x=15
x=3.1400001049041748
Mark.
-----------------------------------------
program precision_test
implicit none
integer, parameter :: sgl = selected_real_kind(p=6)
integer, parameter :: dbl = selected_real_kind(p=15)
real (kind=dbl) :: x
x = dble(3.140000000000000)
write(*,*)'Single precision kind=', sgl
write(*,*)'Double precision kind=', dbl
write(*,*) 'precision of x=', precision(x)
write(*,*) 'x=',dble(x)
end program precision_test
------------------------------------------
The Output I get is:
Single precision kind=4
Double precision kind=8
Precision of x=15
x=3.1400001049041748