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.
| x | y | fmod(x, y) | invalid? |
|---|---|---|---|
| ±0.0 | not 0.0 | ±0.0 | no |
| $(PLUSMNINF) | anything | NaN | yes |
| anything | ±0.0 | NaN | yes |
| !=$(PLUSMNINF) | $(PLUSMNINF) | x | no |
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)));
Calculates the remainder from the calculation x/y.