News for hackers. Stuff that matters.
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:

    $ python
    Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
    [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> x = 1000000000000000001
    >>> x
    1000000000000000001
    >>> x == x + 1
    False

    $ irb
    irb(main):001:0> x = 1000000000000000001
    1000000000000000001
    irb(main):002:0> x == x + 1
    false

    $ clj
    Clojure 1.4.0
    user=> (def x 1000000000000000001)
    #'user/x
    user=> x
    1000000000000000001
    user=> (= (inc x) x)
    false

    $ node
    > x = 1000000000000000001
    1000000000000000000
    > x === x + 1
    true
Re:An Object is not a Hash by ender7 on Tuesday October 09, 2012 @02:04AM (#4630212)
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.

Re:An Object is not a Hash by hythloday on Tuesday October 09, 2012 @07:01AM (#4630887)
"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
  2147483648L
Re:An Object is not a Hash by mietek on Tuesday October 09, 2012 @03:13AM (#4630372)
The difference is, in other programming languages you usually have a choice to use an integer number type.
Re:An Object is not a Hash by redidas on Tuesday October 09, 2012 @01:38AM (#4630142)
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)?

Re:An Object is not a Hash by riffraff on Tuesday October 09, 2012 @04:05AM (#4630501)
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...

Re:An Object is not a Hash by jjm on Tuesday October 09, 2012 @02:33AM (#4630287)