CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Pages

Valid RSS

CMath.h

modf

About | FAQ | Contact
About FAQ Contact

Return integral and fractional parts

viewed 11713 times


+View other versions (3)
Contents -

Interface

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

Description

The modf functions break value into the integral and fractional parts, each of which has the same sign as the argument. They return the fractional part, and store the integral part (as a floating-point number) in the object pointed to by iptr.
Example 1:
#include <math.h>
#include <stdio.h>
 
int main()
{
  double x = 31415.9265, fractional, integer;
  fractional = modf(x, &integer);
  printf("%.4lf = %.4lf + %.4lf\n", x, integer, fractional);
  return 0;
}

Output:
31415.9265 = 31415.0000 + 0.9265

Special Values

modf ( ±∞, iptr) returns ±0 and stores ±∞ in the object pointed to by iptr.
modf ( NaN, iptr) returns a NaN and stores a NaN in the object pointed to by iptr.

See Also

frexp, ldexp

Standards

The modf functions conform to ISO/IEC 9899:1999(E).
Last Modified: 2009-11-01 08:43:32     Page Rendered: 2010-03-14 03:30:33

Page Comments

Format Excel Equations

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional