getNaNPayload

Extract an integral payload from a NaN.

@trusted pure nothrow @nogc
ulong
getNaNPayload
(
real x
)

Return Value

Type: ulong

the integer payload as a ulong.

For floats, the largest possible payload is 0x3F_FFFF. For doubles, it is 0x3_FFFF_FFFF_FFFF. For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF.

Examples

import std.math.traits : isNaN;

real a = NaN(1_000_000);
assert(isNaN(a));
assert(getNaNPayload(a) == 1_000_000);

Meta