Important: The information in this document is obsolete and should not be used for new development.
Creating Infinities and NaNs
MathLib defines the constantsINFINITY
andNAN
, so that you can assign these values to variables in your program, and provides the following function that returns NaNs:
double nan (const char *tagp);Thenan
function returns a quiet NaN with a fraction field that is equal to the argumenttagp
. The argumenttagp
is a pointer to a string that will be copied into bits 8 through 15 of the NaN's fraction field. The string should specify a decimal number between 0 and 255. For example:
nan("32")creates a NaN with code 32. If you supply a negative string, it is the same as supplying the string "0". If you supply a string greater than 255, it is the same as supplying the string "255". For a list of predefined NaN codes, see Chapter 2, "Floating-Point Data Formats."