This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/48906] Wrong rounding results with -m32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48906

--- Comment #33 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-06-10 16:16:19 UTC ---
The last test case I am working is fmt_g0_6.f08. 

The apparent failing case is:

      print "(rc,g15.2)", 0.995000_8

Which is resulting in 0.99 and we expect it to be 1.0.

However, the raw internal representation of 0.995 is not exact and is:

99499999999999999555

This places the value less then the threshold given in the table in the
Standard, giving the correct F format as:

      print "(f11.2,4x)", 0.995000_8  ! 0.99

Instead of 

      print "(f11.1,4x)", 0.995000_8  ! 1.0


Our F formatting in the test case is using the f11.1 and the logic does not
look at the third digit and dutifully rounds the value as it should.  The new G
formatting is using exact integer logic and dutifully does look at the third
digit.

If we do:

print "(rc,g15.2)", 0.9950001_8

The internal value does cross the 0.995 threshold and we do get the 1.0
results.

I think this issues is one of those splitting hairs things.  We could
artificially round the digits string early before we process it, but this would
effectively be rounding twice to get there.  I would prefer to revise the test
case like so:

  call check_all(0.995000000001_RT, 15, 2, 0)

and be done with this.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]