C examples for math.h:modf
function
<cmath> <ctgmath> <math.h>
Breaks x into an integral and a fractional part.
The integer part is stored in the object pointed by intpart, and the fractional part is returned by the function.
Both parts have the same sign as x.
long double modfl (long double x, long double* intpart); long double modf (long double x, long double* intpart); double modf (double x, double* intpart); float modff (float x , float* intpart); double modf (T x , double* intpart);
Parameter | Description |
---|---|
x | Floating point value to break into parts. |
intpart | Pointer to an object where the integral part is stored with the same sign as x. |
The fractional part of x, with the same sign.
#include <stdio.h> #include <math.h> int main ()/*from w ww . j a va 2 s .c o m*/ { double param = 3.14, fractpart, intpart; fractpart = modf (param , &intpart); printf ("%f = %f + %f \n", param, intpart, fractpart); return 0; }