fmod, fmodl
raw OCR
Calculates x modulo y, the remainder of x/y.
Defined in header <math.h>
Syntax
#include <math.h>
double fmod(double x, double y);
long double fmodl(long double x, long double y);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| fmod | ■ | ■ | ■ | ■ | |
| fmodI | ■ | ■ |
Remarks
fmod calculates x modulo y (the remainder /, where x = ay + fior some integer a and 0 < / < y). fmod I is the long double version; it takes long double arguments and returns a long double result.
Return value
fmod and fmodi return the remainder /, where x = ay + f{as described). Where y = 0, fmod and fmod I return 0.
See also
Example
#include <stdio.h>
#include <math.h>
int main (void)
{
double X = 5.0, y = 2.0;
double result;
result = fmod(x,y);
printf("The remainder of (%lf / %lf) is %lf\n", x, y, result);
return 0;
Program output
The remainder of 5.0 / 2.0 is 1.0.
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `f mod, f modi` read as `fmod, fmodl`
Stable link: /3.1/math.h/fmod/
· short form /3.1/fmod/