Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 7 - Numeric Data Types in C


Creating Infinities and NaNs

MathLib defines the constants INFINITY and NAN, 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);
The nan function returns a quiet NaN with a fraction field that is equal to the argument tagp. The argument tagp 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."


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996