Hacker News new | ask | show | jobs
by danwolff 5443 days ago
"NaN-tagging: 64 bit tagged values are used for stack slots and table slots. Unboxed floating-point numbers (doubles) are overlayed with tagged object references. The latter can be distinguished from numbers via the use of special NaNs as tags. It's a remote descendant of pointer-tagging.

[The idea dates back to 2006, but I haven't disclosed it before 2008. Special NaNs have been used to overlay pointers before. Others have used it for tagging later on. The specific layout is of my own devising.]" [1]

[1] http://article.gmane.org/gmane.comp.lang.lua.general/58908

1 comments

Interesting, but I don't think I fully understand when you'd use it. Why would you need to couple object references with floating-point values?
Uneducated conjecture: They're not just any floating points, they are doubles. You need twice the capacity of one (32-bit double) in order to fake 64 bits. I assume that this helps meet the requirements of other pieces being hacked together.