# modfl Function

Splits a long double precision floating-point value into fractional and integer parts.

Include

<math.h>

Prototype

long double modfl(long double x, long double * pint);

Arguments

 x long double precision floating-point value pint pointer to where the integer part should be stored

Return Value

Returns the signed fractional part and pint points to the integer part.

Remarks

The absolute value of the fractional part is in the range of 0 (inclusive) to 1 (exclusive). No domain or range error will occur.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>

int main(void)
{
long double x, y, n;

x = 0.707;
y = modfl(x, &n);
printf("For %Lf the fraction is %Lf\n ", x, y);
printf("  and the integer is %0.Lf\n\n", n);

x = -15.2121;
y = modfl(x, &n);
printf("For %Lf the fraction is %Lf\n ", x, y);
printf("  and the integer is %0.Lf\n\n", n);
}

Example Output

For 0.707000 the fraction is 0.707000
and the integer is 0

For -15.212100 the fraction is -0.212100
and the integer is -15