The OpenD Programming Language

fmod

Calculates the remainder from the calculation x/y.

@trusted nothrow @nogc
real
fmod
(
real x
,
real y
)

Return Value

Type: real

The value of x - i * y, where i is the number of times that y can be completely subtracted from x. The result has the same sign as x.

Special Values
xyfmod(x, y)invalid?
±0.0not 0.0±0.0no
$(PLUSMNINF)anythingNaNyes
anything±0.0NaNyes
!=$(PLUSMNINF)$(PLUSMNINF)xno

Examples

import std.math.operations : feqrel;
import std.math.traits : isIdentical, isNaN;

assert(isIdentical(fmod(0.0, 1.0), 0.0));
assert(fmod(5.0, 3.0).feqrel(2.0) > 16);
assert(isNaN(fmod(5.0, 0.0)));

Meta