다음을 통해 공유


modf

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

doublemodf(doublex**,double*intptr);**

Routine Required Header Compatibility
modf <math.h> ANSI, Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

This function returns the signed fractional portion of x. There is no error return.

Parameters

x

Floating-point value

intptr

Pointer to stored integer portion

Remarks

The modf function breaks down the floating-point value x into fractional and integer parts, each of which has the same sign as x. The signed fractional portion of x is returned. The integer portion is stored as a floating-point value at intptr.

Example

/* MODF.C */

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

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

   x = -14.87654321;      /* Divide x into its fractional */
   y = modf( x, &n );     /* and integer parts            */

   printf( "For %f, the fraction is %f and the integer is %.f\n",
           x, y, n );
}

Output

For -14.876543, the fraction is -0.876543 and the integer is -14

Floating-Point Support Routines, Long Double

See Also   frexp, ldexp