[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


modf

Separate integer and fractional parts.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <math.h>

double modf(double value, double *iptr);
float fmodf(float value, float *iptr);
long double modfl(long double value, 
   long double *iptr);
Parameters:

Parameters for this function are:

value  
double, float, or long double  
The value to separate  
iptr  
double, float, or long double  
integer part  

Remarks:

The modf() function separates value into its integer and fractional parts. In other words, modf() separates value such that value = f + i where 0 £ f < 1, and i is the largest integer that is not greater than value.

Return:

modf() returns the signed fractional part of value, and stores the integer part in the integer pointed to by iptr.

See Also:

"frexp"

"ldexp"

Example of modf() usage.:
#include <math.h>
#include <stdio.h>

int main(void)
{
	double i, f, value = 27.04;
	
	f = modf(value, &i);
	printf("The fractional part of %f is %f.\n", value, f);
	printf("The integer part of %f is %f.\n", value, i);

	return 0;
}

Output:
The fractional part of 27.040000 is 0.040000.
The integer part of 27.040000 is 27.000000.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000