double remainder (double numer , double denom); float remainderf (float numer , float denom);long double remainderl (long double numer, long double denom);
double remainder (double numer , double denom); float remainder (float numer , float denom);long double remainder (long double numer, long double denom); double remainder (Type1 numer , Type2 denom); // additional overloads
Compute remainder (IEC 60559)
Returns the floating-point remainder of numer/denom (rounded to nearest):
remainder = numer - rquot * denom
Where rquot is the result of: numer/denom, rounded toward the nearest integral value (with halfway cases rounded toward the even number).
A similar function, fmod, returns the same but with the quotient truncated (rounded towards zero) instead.
The function remquo has a behavior identical to this function, but it additionally provides access to the intermediate quotient value used.
provides a type-generic macro version of this function.
are provided in this header (
) for other combinations of arithmetic types
): These overloads effectively cast its arguments to
before calculations, except if at least one of the arguments is of type
(in which case both are casted to
- Value of the quotient numerator.
- Value of the quotient denominator.
The remainder of dividing the arguments.
If this remainder is zero, its sign shall be that of numer.
If denom is zero, the function may either return zero or cause a domain error (depending on the library implementation).
If a domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.
/* remainder example */
#include <stdio.h> /* printf */
#include <math.h> /* remainder */
int main ()
printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) );
printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) );
remainder of 5.3 / 2 is -0.700000
remainder of 18.5 / 4.2 is 1.700000
- Compute remainder of division (function)
- Compute absolute value (function)
- Round to nearest (function)