modf, modff
Splits a floating-point value into fractional and integer parts.
double modf( double x, double *intptr ); float modf( float x, float *intptr ); // C++ only long double modf( long double x, long double * intptr ); // C++ only float modff( float x, float *intptr );
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.
modf has an implementation that uses Streaming SIMD Extensions 2 (SSE2). See _set_SSE2_enable for information and restrictions on using the SSE2 implementation.
C++ allows overloading, so you can call overloads of modf. In a C program, modf always takes two double values and returns a double value.
|
Routine |
Required header |
|---|---|
|
modf, modff |
<math.h> |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
#define modff(x,y) ((float)modf((double)(x), (double *)(y)))
Older math.h (VC98, WinDDK3790) use a proper inline function.
inline float modff(float _X, float *_Y)
{ double _Di, _Df = modf((double)_X, &_Di);
*_Y = (float)_Di;
return ((float)_Df); }
Beside the memory corruption also the data alignment may be worse.
- 6/3/2011
- Michael Brüstle