πŸ“NaN-boxing

NaN-boxing is a value-packing technique.

Double-precision NaNs come with a 51 bits of payload (that were supposed to describe the error). Only a couple of the codes are actually emitted by hardware, though. So the rest of possible values can be reused to store additional information.

51 bits is even enough to pack a pointer on a 64-bit machine (because 64-bit machines don’t use full 64-bit address space).

See also

Backlinks