Re:WTFJS?
by mrcharles on Friday February 12, 2010 @05:31PM
(#1121986)
Wouldn't that have more to do with the fact that javascript uses floats for everything? It's probably exceeding precision at a guess.
[ Parent
| on HN ]
Is it? I thought Javascript has integer type.
Say for example Lua (by default) is configured to use only double. It can be configured to use single-float, or even integer - but only one numeric type.
Standard JavaScript uses doubles everywhere. They get casted to 32-bit signed integers for bitwise operations, the results are casted back. It's a little odd, but consistent at least.
A little odd and a lot slow, if you do them a lot (js-protobuf, I'm looking at you).
Execution tracing should eliminate the cast if it is not necessary.