I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCMath.h

fmodl

Floating-point remainder function
+ View other versions (4)

Interface

#include <math.h>
double fmod (double x, double y)
long fmodl (long double x, long double y)
float fmodf (float x, float y)

Description

The fmod functions compute the floating-point remainder of dividing x by y.

The return value is x - n y, where n is the quotient of x / y, rounded to the first integer towards zero.

Example:
Example - Floating-point remainder function
Workings
#include <stdio.h>
#include <math.h>
int main(void)
{
  double x = 2*3.1415926 + 0.14527, y = 3.1415926;
  printf("fmod(x, y) = %.5lf\n", fmod(x, y));
  return 0;
}
Solution
Output:
fmod(x, y) = 0.14527

Special Values

fmod ( ±0, y ) returns ±0 for y not zero.

fmod ( x, y ) returns a NaN and raises the invalid floating-point exception for x infinite or y zero.

fmod ( x, ±∞ ) returns x for x not infinite.

Standards

The fmod functions conform to ISO/IEC 9899:1999(E).