modf
, modff
---split fractional and integer parts#include <math.h> double modf(double val, double *ipart); float modff(float val, float *ipart);
Description
modf
splits the double val apart into an integer part
and a fractional part, returning the fractional part and
storing the integer part in *ipart
. No rounding
whatsoever is done; the sum of the integer and fractional
parts is guaranteed to be exactly equal to val. That
is, if . realpart = modf(val, &intpart); then
`realpart+intpart
' is the same as val.
modff
is identical, save that it takes and returns
float
rather than double
values.
Returns
The fractional part is returned. Each result has the same
sign as the supplied argument val.
Portability
modf
is ANSI C. modff
is an extension.
Go to the first, previous, next, last section, table of contents.