Skip to content

Instantly share code, notes, and snippets.

@madrobby
Created January 17, 2013 15:15
Show Gist options
  • Save madrobby/4556637 to your computer and use it in GitHub Desktop.
Save madrobby/4556637 to your computer and use it in GitHub Desktop.
$ irb
irb(main):001:0> 10000000000000000 == 10000000000000001
=> false
$ node
> 10000000000000000 == 10000000000000001
true
@alloy
Copy link

alloy commented Jan 17, 2013

It is clear that JS+Node scale better, they can do more comparisons with only one object!

» /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
> 10000000000000000 == 10000000000000001
true
> 10000000000000000 == 10000000000000000
true
> 10000000000000000 == 9999999999999999
true

@ThisIsMissEm
Copy link

Is this because of the actual size of the number and how it is stored? I'm thinking similar to the 0.2 + 0.1 == 0.3 bug.

@jwarchol
Copy link

JS stores numbers as floating point values only, no true integers, and only 53 bits precision for the left side of the decimal (I think).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment