|
|
HP-UX/HP C Compiler: HP C/HP-UX Reference Manual > Chapter 10 HP C/HP-UX Implementation
Topics IEEE Floating-Point Format |
|
The internal representation of floating-point numbers conforms to the IEEE floating-point standard, ANSI/IEEE 754-1985, as shown in figure 10-1. The s field contains the sign of the number. The exp field contains the biased exponent (exp = E + bias, where E is the real exponent) of the number. The values of bias and the maximum and minimum values of the unbiased exponent appear in the following table: Table 10-2 Floating-point Bias, and Unbiased Exponents Values
Emin-1 is used to encode 0 and denormalized numbers. Emax+1 is used to encode infinities and NaNs. NaNs are binary floating-point numbers that have all ones in the exponent and a nonzero fraction. NaN is the term used for a binary floating-point number that has no value (that is, "Not A Number"). If E is within the range Emin <= E <= Emax the mantissa field contains the number in a normalized form, preceded by an implicit 1 and binary point. In accordance with the IEEE standard, floating-point operations are performed with traps not enabled, and the result of such an operation is that defined by the standard. This means, for example, that dividing a positive finite number by zero will yield positive infinity, and no trap will occur. Dividing zero by zero or infinity by infinity will yield a NaN, again with no trap. For a discussion of infinity arithmetic and operations with NaNs, in the context of the IEEE standard, see the HP Precision Architecture and Instruction Set Reference Manual (HP part number 09740-90014). For detailed information about floating-point arithmetic on HP-UX, how HP-UX implements the IEEE standard, and the HP-UX math libraries, see the HP-UX Floating Point Guide. Note that infinities and NaNs propagate through a sequence of operations. For example, adding any finite number to infinity will yield infinity. An operation on a NaN will yield a NaN. This means that you may be able to perform a sequence of calculations and then check just the final result for infinity or NaN. The HP-UX math library provides routines for determining the class of a floating point number. For example, you can determine if a number is infinity or NAN. See the HP-UX Reference for descriptions of the functions fpclassify, fpclassifyf, isinf, and isnan. |
|