The fractional part of x.
x | i (on input) | modf(x, i) | i (on return) |
---|---|---|---|
$(PLUSMNINF) | anything | ±0.0 | $(PLUSMNINF) |
import std.math.operations : feqrel; real frac; real intpart; frac = modf(3.14159, intpart); assert(intpart.feqrel(3.0) > 16); assert(frac.feqrel(0.14159) > 16);
Breaks x into an integral part and a fractional part, each of which has the same sign as x. The integral part is stored in i.