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
Function Required Header Compatibility
floor <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
The floor function returns a floating-point value representing the largest integer that is less than or equal to x.There is no error return.
Parameter
x
Floating-point value
Example
/* FLOOR.C: This example displays the largest integers
* less than or equal to the floating-point values 2.8
* and -2.8. It then shows the smallest integers greater
* than or equal to 2.8 and -2.8.
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double y;
y = floor( 2.8 );
printf( "The floor of 2.8 is %f\n", y );
y = floor( -2.8 );
printf( "The floor of -2.8 is %f\n", y );
y = ceil( 2.8 );
printf( "The ceil of 2.8 is %f\n", y );
y = ceil( -2.8 );
printf( "The ceil of -2.8 is %f\n", y );
}
Output
The floor of 2.8 is 2.000000
The floor of -2.8 is -3.000000
The ceil of 2.8 is 3.000000
The ceil of -2.8 is -2.000000