I use Visual Studio (2010 SP1) with Fortran IMSL (2011) and I can't get the right precision for my reals:
program prova
use, intrinsic :: iso_fortran_env
implicit none
integer, parameter :: ikind=selected_real_kind(p=8, r=99)
real(kind=ikind) :: a=0.79
real(real64) :: b=0.79
real(kind=16) :: c=0.79
real(8) :: d=0.79
print *, a
print *, b
print *, c
print *, d
end program prova
give me the same result: 0.790000021457672
(one with more precision, one with less precision but every number is different from the assigned one: 0.79)
Why my willingness is not respected?
How can I set all reals to the needed precision?
NB: my problem has nothing to do with the "limited nature of computer", roundoff numbers and similar. my problem regards type/kind of variable in Fortran.