Important: The information in this document is obsolete and should not be used for new development.
Creating Infinities and NaNs
MathLib defines the constantsINFINITYandNAN, 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);Thenanfunction returns a quiet NaN with a fraction field that is equal to the argumenttagp. The argumenttagpis 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."
 
  
  
 