This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Int cast / floating point isuses
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: "Joe Hughes" <jhughesjr at comcast dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 24 Jul 2004 12:55:56 +0100
- Subject: Re: Int cast / floating point isuses
- References: <410163AF.8000307@comcast.net>
"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/