airbnb / javascript

JavaScript Style Guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitshift performance vs 64bit numbers

bc99 opened this issue · comments

commented

Every number is stored with 64bit, except you are doing bit shifting. Then javascript stores the number into a 32bit integer. The result of this: You get negative or just wrong numbers when you are shifting a big js-representing integer.
If you really think bit shift is a good way to improve performance, make sure the numbers are not bigger than 32 bit.

@tbcm interesting, maybe you should provide some examples for the guide

commented

I had found a good website about this a few weeks ago, because I ran into this issue. I cannot find it anymore, but here is a stackoverflow link:
http://stackoverflow.com/questions/2373791/bitshift-in-javascript

At the moment I'm very busy, so I cannot create an example. I just thought it would be good to know.

Ah! Thanks for pointing this out. 🍻

🍻 thank you!