#include
<cmath>
double remainder (double x, double y)
Liefert $r = x - n y$ mit nächstgelegenem ganzzahligen Quotienten $n$. Bei $|n - x/y| = 0.5$ ist $n$ gerade.
x | Dividend |
y | Divisor ungleich 0 |
Rückgabewert: x
REM y
nach IEC 60559.
#include <cmath> #include <iostream> int main() { double x = 13, y = 5; std::cout << "Der Rest von " << x << '/' << x << " ist " << std::remainder(x, y) << '\n'; }