Rate This Document
Findability
Accuracy
Completeness
Readability

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

  • For modff, x is of single-precision floating-point type.
  • For modf, x is of double-precision floating-point type.
  • For modfl, x is of long double-precision floating-point type.

Floating-point value of the input data.

Input

iptr

  • For modff, iptr is of single-precision floating-point type.
  • For modf, iptr is of double-precision floating-point type.
  • For modfl, iptr is of long double-precision floating-point type.

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
     * */