Name

modf, modff, modfl
- extract signed integral and fractional values from floating-point number

Library

libc.lib

Synopsis

  #include <math.h>
  double modf (double value, double *iptr);
  float modff (float value, float *iptr);
  long double modfl (long double value, long double *iptr);

Return values

The modf modff and modfl functions return the signed fractional part of a value.

Detailed description

The modf function breaks the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by iptr. The function modff (is, the, float, version, of, modf().);
The function modfl is an alias to the function modf.

Examples

#include <math.h>
#include <stdio.h>
int main()
{
   double x1 = 123.456703 , y;
   double  iptr;
   float fptr;
   y = modf( x1, &iptr );
   printf( "modf(%f , &iptr):: Int Part: %f and Fractional Part: %f 0, x1, iptr, y );
   y = modff( x1, &fptr );
   printf( "modff(%f , &iptr):: Int Part: %f and Fractional Part: %f 0, x1, fptr, y );
   y = modfl( x1, &iptr );
   printf( "modfl(%f , &iptr):: Int Part: %f and Fractional Part: %f 0, x1, iptr, y );
}

         

Output

modf ( 123.456703 , &iptr ) :: Int Part: 123 and Fractional Part: 0.456703
modff( 123.456703,  &iptr ) :: Int Part: 123 and Fractional Part: 0.456703
modfl( 123.456703,  &iptr ) :: Int Part: 123 and Fractional Part: 0.456703

         


See also

frexp, ldexp, math

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top