Rounding Error
Eric Mercer
eemercer@yuan.elen.utah.edu
Thu Sep 17 12:48:00 GMT 1998
> It's just rounding error.
Normally I would agree, but there are a few things that make this weird:
1) The floor and ceil return the same value, meaning that the
result is already a double with no fractional portion,
otherwise floor and ceil would have been different.
2) If you use a constant for the value tolerance, the correct
answer is obtained.
3) If you type cast the floor or ceil of the value to an integer,
the correct answer is obtained, even though the bit pattern
of the value is identical before and after the call to floor
or ceil.
4) If you assign the result to a temporary double and then typecast
the temporary double, you get the correct answer.
5) Other machine architectures ( not Intel ) execute the code
correctly.
egm
More information about the Gcc-bugs
mailing list