Re:An Object is not a Hash
by snprbob86 on Tuesday October 09, 2012 @01:28AM
(#4630108)
JavaScript's Number type is double floating point:
[ Parent
| on HN ]
I don't see how this is any different from overflowing an int32 in any other programming language. Sure, with an int, x != x + 1 even after an overflow, but your program is still going to crash when it tries to bill you for negative two billion widgets.
If you're dancing on the edge of the limits of numerical representation then you need to write code to protect against bad things. If you don't write said code, your program is going to fail to work correctly, no matter what language you use.
"Overflowing an int" is something that I worry about when I'm thinking in terms of memory layout of data. I shouldn't have to worry about it when working at a higher level of abstraction. Python handles this correctly:
>>> int('0x7fffffff', 16)
2147483647
>>> int('0x7fffffff', 16) + 1
2147483648LThe difference is, in other programming languages you usually have a choice to use an integer number type.
Thanks for the example.
I'm curious as to why this discounts a tool meant for performing IO and various web development tasks in general.
Has anyone run into a integer math related issue when using node (that was a deal-breaker)?
people usually run into the issue from time to time when using JSON to transmit numbers to a javascript process, for example[0][1][2]
[0] http://stackoverflow.com/questions/8663298/json-transfer-of-...
[1] http://stackoverflow.com/questions/6320908/twitter-json-in-r...
[2] http://stackoverflow.com/questions/209869/what-is-the-accept...
Don't be scared, see https://github.com/JasonGiedymin/pi-node