You are using a version without Ads of this website. Please, consider donating:
function
<cmath> <ctgmath>

# remainder

```     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):

fmod = 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.

Header <tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (`<cmath>`) for other combinations of arithmetic types (Type1 and 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).

### Parameters

numer
Value of the quotient numerator.
denom
Value of the quotient denominator.

### Return Value

The remainder of dividing the arguments.
If this remainder is zero, its sign shall be that of x.
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.

### Example

 ``12345678910`` ``````/* remainder example */ #include /* printf */ #include /* 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) ); return 0; }``````

Output:
 ``` fmod of 5.3 / 2 is -0.700000 fmod of 18.5 / 4.2 is 1.700000 ```