DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Floating point operations

NaNs and infinities

The floating point system supports two special representations:


Infinity
Positive infinity in a format compares greater than all other representable numbers in the same format. Arithmetic operations on infinities are quite intuitive. For example, adding any representable number to infinity is a valid operation the result of which is positive infinity. Subtracting positive infinity from itself is invalid. If some arithmetic operation overflows, and the overflow trap is disabled, in some rounding modes the result is infinity.

Not-a-Number (NaN)
These floating point representations are not numbers. They can be used to carry diagnostic information. There are two kinds of NaNs: signaling NaNs and quiet NaNs. Signaling NaNs raise the invalid operation exception whenever they are used as operands in floating point operations. Quiet NaNs propagate through most operations without raising any exception. The result of these operations is the same quiet NaN. NaNs are sometimes produced by the arithmetic operations themselves. For example, 0.0 divided by 0.0, when the invalid operation trap is disabled, produces a quiet NaN.
The header file ieeefp.h defines the interface for the floating point exception and environment control. This header defines three interfaces:
Next topic: Rounding control
Previous topic: Special-case values

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003