remainder

fnreal remainder(real x, real y) @trusted nothrow @nogc

Calculate the remainder x REM y, following IEC 60559.

REM is the value of x - y * n, where n is the integer nearest the exact value of x / y. If |n - x / y| == 0.5, n is even. If the result is zero, it has the same sign as x. Otherwise, the sign of the result is the sign of x / y. Precision mode has no effect on the remainder functions.

remquo returns n in the parameter n.

x y remainder(x, y) n invalid?
±0.0 not 0.0 ±0.0 0.0 no
+∞ anything -NaN ? yes
anything ±0.0 ±NaN ? yes
!= +∞ +∞ x ? no