Int cast / floating point isuses

Brian Gough bjg@network-theory.co.uk
Sat Jul 24 12:00:00 GMT 2004


"Joe Hughes" <jhughesjr@comcast.net> writes:

> I'm stumped as to what is causing this error to occur for int cast,
> especially when lrint and trunc seem to work properly.
> 
> Any insight anyone has would be much appreciated.

The default with gcc on x86 is to use 80-bit extended precision
registers, compared with 64-bit on the other architecture.  It gives a
differently rounded result in this case, since the underlying binary
representation is on the borderline between -79.937384... and
-79.9373839999...

Use the rint type functions to round to the nearest integer reliably.

-- 
Brian Gough

Network Theory Ltd,
Publishing "An Introduction to GCC" --- http://www.network-theory.co.uk/



More information about the Gcc-help mailing list