Rounding errors using doubles?

Joe Buck jbuck@Synopsys.COM
Thu Mar 18 16:12:00 GMT 1999


> On a Pentium II, the following code gives an incorrect result when using
> doubles, but a correct result when using floats:

Take it to a beginner's programming group.  (Hint: .86 can't be
represented exactly in floating point, the nearest IEEE float is
a hair above .86, the nearest IEEE double is a hair below .86;
in C, conversion from float or double to integer truncates, it does not
round).

> This is VERY bad for our software.

Any compiler will be very bad for your software, until you learn how
to use floating point.


More information about the Gcc mailing list