— —
IEEE 754 binary64
tagged-value interpretations
doubles
edges
JavaScriptCore
LuaJIT
SpiderMonkey
recently viewed
quick reference
a NaN is any binary64 value where the
exponent field is all-ones (0x7FF) and the mantissa is non-zero.
that leaves 1 sign bit + 52 mantissa bits = 53 bits of free
space inside the NaN encoding.
quiet NaN: MSB of mantissa is 1. signaling NaN: MSB of mantissa is 0 (mantissa still non-zero). all production NaN-boxing engines use quiet NaNs only, because x87 silently quiets sNaNs on load.
JavaScriptCore stores pointers
in the low 48 bits and uses the 0x0002000000000000 offset for
doubles. LuaJIT stores doubles
verbatim and tags non-doubles by placing a value of 0xFFF8–0xFFFF
in the top 16 bits, which sits safely inside the NaN-encoding window above
any plausible x86-64 user-space pointer. SpiderMonkey's
historical punbox64 scheme carves a 4-bit type tag out of bits 47–50 once the
top 16 bits sit at or above 0xFFF0.
don't have a hex string handy? type a plain number into the "or a number"
field — 3.14, -0, Infinity,
NaN — and it encodes to bits the same way DataView
would. every distinct value you visit (by bit, preset, or typed) gets kept
in recently viewed below the presets, up to twelve, saved to this
browser so it survives a reload.