I'm new to Fortran, so forgive me if I'm doing something stupid in the following code:
program test2
implicit none
! Variable declaration
integer :: i, n
real :: s
! Initialization
n = 1e+9
s = 0.0
do i=1,n
s = s + real(i)
s = s + sqrt(s)
end do
print *, s
end program test2
This small program outputs: 1.8014399E+16 and I expect it to give 1.0000000010000024E+18. I use the GNU Fortran compiler on a Windows 10 machine.
real ::stodouble precision :: sdo you get the answer you expect?kind = 16,real*16, etc, but all didn't work, do you know why?