The OpenD Programming Language

modf

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.

@trusted nothrow @nogc
real
modf
(
real x
,
ref real i
)

Return Value

Type: real

The fractional part of x.

Special Values
xi (on input)modf(x, i)i (on return)
$(PLUSMNINF)anything±0.0$(PLUSMNINF)

Examples

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);

Meta