##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::remainder

From cppreference.com
< cpp‎ | numeric‎ | math

Defined in header `<cmath>` |  |
float remainder( float x, float y ); | (1) | (since C++11)
double remainder( double x, double y ); | (2) | (since C++11)
long double remainder( long double x, long double y ); | (3) | (since C++11)
Promoted remainder( Arithmetic1 x, Arithmetic2 y ); | (4) | (since C++11)

Computes the signed remainder of the floating point division operation x/y.

Specifically, the returned value is x - n*y, where `n` is x/y rounded to the nearest integer, or the nearest even integer if x/y is halfway between two integers.

In contrast to std::fmod(), the returned value is not guaranteed to have the same sign as `x`.

If the returned value is `0`, it will have the same sign as `x`.

4) If any argument has integral type, it is cast to double. If any other argument is long double, then the return type is long double, otherwise it is double

### [edit] Parameters

x, y | - | values of floating-point or integral types

### [edit] Return value

Remainder of dividing arguments.

### [edit] See also

fmod | remainder of the floating point division operation (function) [edit]
div ldiv lldiv imaxdiv (C++11) | the quotient and remainder of integer division (function) [edit]
C documentation for remainder

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/numeric/math/remainder&oldid=67118"