question on double to int conversion
Andrew Haley
aph@redhat.com
Sat May 22 10:39:00 GMT 2004
Richard Henderson writes:
> On Fri, May 21, 2004 at 10:55:43AM +0900, Jaeyoun Chung wrote:
> > To be ieee 754 compliant, '%x' output should be 7fffffff and 80000000,
>
> Who says?
> ISO C says float->int conversion overflow is undefined.
Section 5.4 of IEEE 754, "Conversion Between Floating-Point and
Integer Formats", refers to Section 7.1, which says you get an Invalid
Operation exception for this case.
Section 7.3 says "when no trap occurs ... round towards zero carries
all overflows to the format's largest number with the sign of the
intermediate result".
However, ISO C, Section F.4 says of floating-point to integer overflow,
"the resulting value is unspecified."
Andrew.
More information about the Gcc
mailing list