Skip to content

Instantly share code, notes, and snippets.

@BrendanEich
Created August 17, 2011 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrendanEich/1152895 to your computer and use it in GitHub Desktop.
Save BrendanEich/1152895 to your computer and use it in GitHub Desktop.
typed array vs. number type
js> b = new ArrayBuffer(64)
({})
js> a = new Uint32Array(b)
({0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0, 10:0, 11:0, 12:0, 13:0, 14:0, 15:0})
js> a[0]
0
js> a[0] = Math.pow(2,32)
4294967296
js> a[0]
0
js> a[0] = Math.pow(2,52)
4503599627370496
js> a[0]
0
js> a[0] = Math.pow(2,52)+1
4503599627370497
js> a[0]
1
js> a[0] = Math.pow(2,53)
9007199254740992
js> a[0]
0
js> a[0] = Math.pow(2,53)+1
9007199254740992
js> a[0]
0
js> a[0] = Math.pow(2,53)+2
9007199254740994
js> a[0]
2
@BrendanEich
Copy link
Author

Copy/paste glitch fixed. Hope this is clear enough now.

/be

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