gcc strangeness

Dimitry Andric dimitry at andric.com
Sun Jul 11 10:40:46 PDT 2004


On 2004-07-11 at 19:06:32 Dmitry Morozovsky wrote:

> 1.000000 1.000 0
> 2.000000 2.000 1
> 3.000000 3.000 2
> 4.000000 4.000 3
> 5.000000 5.000 5
> 6.000000 6.000 6
> 7.000000 7.000 7
> 8.000000 8.000 7
> 9.000000 9.000 8
> 9.999999 10.000 9

Yes, this is completely normal if you use IEEE floating point, due to
decimal <-> binary conversion and other accumulating rounding errors.
In other words, floating point calculations will almost never be
exact...

This is not a gcc problem.  In fact, I can even reproduce your output
under Windows using a Microsoft C compiler! :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 183 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20040711/3b389996/attachment.bin


More information about the freebsd-hackers mailing list