nan-box

53 free bits inside an IEEE 754 NaN. click any bit to flip. for {{name}}.

sign · 1 bit exponent · 11 bits mantissa · 52 bits
0x

IEEE 754 binary64

sign
biased exponent
unbiased exponent
mantissa (hex)
decoded value

tagged-value interpretations

JavaScriptCore
LuaJIT 2
SpiderMonkey-ish
payload (low 48)
payload (low 47)

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 0xFFF80xFFFF in the top 16 bits, which sits safely inside the NaN-encoding window above any plausible x86-64 user-space pointer.