How many significant decimal digits for real single precision?

Found it!

Here it is (thanks @kargl for the tip how to find it!):

1.00000048

That requires all 9 digits to print. If you only print 8 digits, and read it back, you get 1.00000036, which is a different number. Test code:

real :: x
x = 1.00000048
print *, x
x = 1.0000004
print *, x
end

This prints:

   1.00000048    
   1.00000036    

Conclusion: you need to print 9 digits for single precision and 17 digits for double precision to not lose any accuracy.

2 Likes