This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/33469] Default formats for real input are not precise enough
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Oct 2007 23:28:40 -0000
- Subject: [Bug libfortran/33469] Default formats for real input are not precise enough
- References: <bug-33469-12313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from fxcoudert at gcc dot gnu dot org 2007-10-01 23:28 -------
Hum, the real(16) case looks like loads of fun to come!
$ cat k.f90
integer, parameter :: k = 16
character(80) :: buf
real(k) :: xk, yk
xk = 1.0_k - epsilon(xk)
write (buf,'(1PG60.40)') xk
read (buf,*) yk
write (*,'(1PG60.40)') xk
write (*,'(1PG60.40)') yk
if (xk /= yk) print *, "Mismatch"
print *
xk = 1.0_k + epsilon(xk)
write (buf,'(1PG60.40)') xk
read (buf,*) yk
write (*,'(1PG60.40)') xk
write (*,'(1PG60.40)') yk
if (xk /= yk) print *, "Mismatch"
print *
end
$ gfortran k.f90 && ./a.out
1.9999999999999999999999999999999753481000
4.9303806576313237838233035330174139355000E-32
Mismatch
1.0000000000000000000000000000000246519000
1.0000000000000000000000000000000246519000
(Also, in the case of real(16), you need to add an E4 to the format anyway.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33469