News for hackers. Stuff that matters.
Re:WTFJS? by jrockway on Friday February 12, 2010 @05:25PM (#1121974)
I am no fan of Javascript, but most of these WTFs make sense to me. The 111111111100 one is unexpected, although there is probably a good explanation. (Like "alert takes a string, you passed a number. nasal demons.")
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.
Re:WTFJS? by malkia on Friday February 12, 2010 @05:48PM (#1122035)
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.

Re:WTFJS? by pmjordan on Friday February 12, 2010 @06:18PM (#1122103)
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.
Re:WTFJS? by andreyf on Friday February 12, 2010 @09:28PM (#1122415)
A little odd and a lot slow, if you do them a lot (js-protobuf, I'm looking at you).
Re:WTFJS? by jrockway on Saturday February 13, 2010 @04:34AM (#1122819)
Execution tracing should eliminate the cast if it is not necessary.
Re:WTFJS? by mrcharles on Saturday February 13, 2010 @12:41AM (#1122614)
Ah. I don't know the inner workings of Javascript so I'm not surprised I was wrong. Just at a glance, that problem to me screams floating point limitation.
Re:WTFJS? by tedunangst on Friday February 12, 2010 @06:42PM (#1122165)
Indeed. I would have expected 415003079.