Next: , Previous: fmin, Up: Math


1.25 fmod, fmodf—floating-point remainder (modulo)

Synopsis

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

Description
The fmod and fmodf functions compute the floating-point remainder of x/y (x modulo y).


Returns
The fmod function returns the value x-i*y, for the largest integer i such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y.

fmod(x,0) returns NaN, and sets errno to EDOM.

You can modify error treatment for these functions using matherr.


Portability
fmod is ANSI C. fmodf is an extension.