Floating-point to integer conversion and IEEE-754

Fred Tydeman uunet!ibminet.awdpa.ibm.com!ibmpa!tydeman
Wed Feb 10 08:34:13 PST 1993


Consider the simple assignment:
 
   i = 1.0e300;   /* Convert floating-point to integer; overflow */
 
What does IEEE 754-1985 say should happen, in the non-trapping case?
 
Section 7.1  Invalid Operation
      (7) Conversion of a binary floating-point number to an integer
      or decimal format when overflow, infinity, or NaN precludes a
      faithful representation in that format and this cannot otherwise
      be signaled.
 
Section 7.3  Overflow
      The overflow exception shall be signaled whenever the destination
      format's largest finite number is exceeded in magnitude by what
      would have been the rounded floating-point result (section 4) were
      the exponent range unbounded.
 
Section 7.5  Inexact
      If the rounded result of an operation is not exact or if
      it overflows without an overflow trap, then the inexact
      exception shall be signaled.
 
However, the third paragraph of Section 7.0 is:
 
      The only exceptions that can coincide are inexact with
      overflow and inexact with underflow.
 
I see three possible results for which exceptions are raised:
  1)  Invalid operation
  2)  Overflow and inexact
  3)  Invalid operation, overflow, and inexact
 
Comments?
 
These are not IBM's views, these are the personal ones of:
Fred Tydeman, IBM, Austin, Texas (512) 838-3322; fax (512) 838-3484
AIX S/6000 Math library architect & IBM's rep to NCEG (X3J11.1)
Internet: tydemanaibmpa.awdpa.ibm.com    uucp: uunet!ibmsupt!tydeman



More information about the Numeric-interest mailing list