4 ms·
I think you are thinking about a different trick called NaN tagging. http://wingolog.org/archives/2011/05/18/value-representation-in-javascript-implementations
by ufo 12y ago
I think you are thinking about a different trick called NaN tagging.
http://wingolog.org/archives/2011/05/18/value-representation-in-javascript-implementations http://wingolog.org/archives/2011/05/18/value-representation...
The basic idea is that there are 2^53 different bit patterns that are counted as NaN by the computer but only one is actually used in practice. This means that you can "steal" the rest of the NaNs and use them to encode numbers or pointers.
- munificent 12y agoI'm hacking on a fast little dynamically-typed language that uses that technique. It works fantastically well. I describe it in detail here: https://github.com/munificent/wren/blob/master/src/wren_value.h#L400 https://github.com/munificent/wren/blob/master/src/wren_valu...
- ufo 12y agoThanks for the link! I was actually surprised how hard it was to find a good description of NaN tagging yesterday.