This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question on double to int conversion


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]