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 10 - Transcendental Functions /


modf

You can use the modf function to split a real number into a fractional part and an integer part.

float modff (float x, float *iptrf);
double modf (double x, double *iptr);
x
Any floating-point number.
iptr
A pointer to a floating-point variable in which the integer part can be stored upon return.
DESCRIPTION
The modf function splits its first argument into a fractional part and an integer part. This is an ANSI standard C function.

 such that |f| < 1.0 and 
The fractional part is returned as the value of the function, and the integer part is stored as a floating-point number in the area pointed to by iptr. The fractional part and the integer part both have the same sign as the argument x.

EXCEPTIONS
If x is finite and nonzero, the result of modf(x,n) is exact.

SPECIAL CASES
Table 10-19 shows the results when the floating-point argument to the modf function is a zero, a NaN, or an Infinity.
Special cases for the modf function
OperationResultExceptions raised
modf(+0,n) +0 (n = 0)None
modf(-0,n) -0 (n = 0)None
modf(NaN,n) NaN (n = NaN)None[40]
modf(+ ,n) +0 (n = + )None
modf(- ,n) -0 (n = - )None

EXAMPLES
z = modf(1.0, n); /* z = 0.0 and n = 1.0 */
z = modf(+INFINITY, n); /* z = 0.0 and n = +INFINITY because the 
                           value +   is an integer. */

[40] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996