function
<cmath> <ctgmath>
fmoddouble fmod (double numer, double denom);
double fmod (double numer , double denom); float fmodf (float numer , float denom);long double fmodl (long double numer, long double denom);
double fmod (double numer , double denom); float fmod (float numer , float denom);long double fmod (long double numer, long double denom);
double fmod (double numer , double denom); float fmod (float numer , float denom);long double fmod (long double numer, long double denom); double fmod (Type1 numer , Type2 denom); // additional overloads
Compute remainder of division
Returns the floating-point remainder of numer/denom (rounded towards zero):fmod = numer - tquot * denom
Where tquot is the truncated (i.e., rounded towards zero) result of: numer/denom.
A similar function, remainder, returns the same but with the quotient rounded to the nearest integer (instead of truncated).
Header
<tgmath.h>provides a type-generic macro version of this function.
are provided in this header (
<cmath>
) for other combinations of
arithmetic types(
Type1and
Type2): These overloads effectively cast its arguments to
double
before calculations, except if at least one of the arguments is of type
long double
(in which case both are casted to
long double
instead).
If a
domain erroroccurs, the global variable
errnois set to
EDOM.
1
2
3
4
5
6
7
8
9
10
/* fmod example */
#include <stdio.h> /* printf */
#include <math.h> /* fmod */
int main ()
{
printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) );
printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) );
return 0;
}
fmod of 5.3 / 2 is 1.300000 fmod of 18.5 / 4.2 is 1.700000
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4