Important: The information in this document is obsolete and should not be used for new development.
modf
You can use themodf
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
Themodf
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 andThe 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 byiptr
. The fractional part and the integer part both have the same sign as the argumentx
.EXCEPTIONS
If x is finite and nonzero, the result of is exact.SPECIAL CASES
Table 10-19 shows the results when the floating-point argument to themodf
function is a zero, a NaN, or an Infinity.
Special cases for the modf
functionOperation Result Exceptions raised +0 (n = 0) None (n = 0) None NaN (n = NaN) None[40] +0 (n = + ) None (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.