modf
Break down the input into fractional and integer parts and return the fractional part. The integer part is stored in the position pointed by iptr.
Interface Definition
C interface:
float modff(float x, float *iptr);
double modf(double x, double *iptr);
long double modfl(long double x, long double *iptr);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
iptr |
|
Pointer to the integer part of the input floating point number. |
Output |
Return Value
The fractional part of the input is returned. The integer part is stored in the position pointed by iptr.
Dependency
C: "km.h"
Example
C interface:
// typical usage
double iptr;
printf("modf(3.4, &iptr) = %.15f, iptr = %.15f\n", modf(3.4, &iptr), iptr);
printf("modf(-4.8, &iptr) = %.15f, iptr = %.15f\n", modf(-4.8, &iptr), iptr);
result
/*
* modf(3.4, &iptr) = 0.400000000000000, iptr = 3.000000000000000
* modf(-4.8, &iptr) = -0.800000000000000, iptr = -4.000000000000000
* */
Parent topic: Function Syntax