Floating-point to integer conversion and IEEE-754

Fred Tydeman uunet!ibminet.awdpa.ibm.com!ibmpa!tydeman
Thu Feb 11 10:01:07 PST 1993


The correct answer, based upon the IEEE-754 and IEEE-854 standards and
the people who wrote the standards and know the unwritten background,
intent, and rational, to my query is:
   i = 1.0e300    /* i has the value of the maximum integer */
Raise Integer Overflow (if your hardware has it), or,
raise Invalid Operation (if there is no other way to indicate the error).
Do not raise Floating-point Overflow nor Inexact.
 
For
   i = 1.0e-200   /* i has the value 0 in round to nearest. */
Raise Inexact.  This is required by IEEE-854, section 5.4.
Do not raise Floating-point Underflow.
 
For
   i = 2.3        /* i has the value 2 in round to nearest. */
Raise Inexact.  This is required by IEEE-854, section 5.4.
 
For
   i = 1.0        /* i has the value 1 */
Do not raise any exceptions as it is exact and representable.
 
Aside:  Several of us do agree that just reading IEEE-754, it is not
clear what should happen in these cases.
 
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