Skip to content

Bitshift performance vs 64bit numbers #109

@bc99

Description

@bc99

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.

Activity

serbanghita

serbanghita commented on Nov 14, 2013

@serbanghita

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

bc99

bc99 commented on Nov 14, 2013

@bc99
Author

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.

hshoff

hshoff commented on Nov 14, 2013

@hshoff
Member

Ah! Thanks for pointing this out. 🍻

serbanghita

serbanghita commented on Nov 14, 2013

@serbanghita

🍻 thank you!

added a commit that references this issue on Feb 5, 2024
8bab767
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hshoff@serbanghita@bc99

        Issue actions

          Bitshift performance vs 64bit numbers · Issue #109 · airbnb/javascript