— —
IEEE 754 binary64
tagged-value interpretations
doubles
edges
JavaScriptCore
LuaJIT
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.