Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there real need for >> 1 and << 1 everywhere? #96

Closed
juanplopes opened this issue Feb 13, 2015 · 3 comments
Closed

Is there real need for >> 1 and << 1 everywhere? #96

juanplopes opened this issue Feb 13, 2015 · 3 comments

Comments

@juanplopes
Copy link
Contributor

Can't modern javascript compilers optimize this kind of instructions? I know this is kind of bikeshedding, but I think using shifts instead of multiplications only sacrifices readability of the code.

@felipernb
Copy link
Owner

Can you point some cases? Sometimes it's the easiest way to force integer division and avoid rounding down float numbers

@juanplopes
Copy link
Contributor Author

Oh sorry, Javascript isn't my strong language. I completely forgot it has no built-in integer division. But the argument is still valid at least for multiplications.

@felipernb
Copy link
Owner

It's not a matter of optimization, but a matter of consistency instead. Wherever << comes as multiplication it's just because in the same piece of code >> is used for division and I wanted to keep the operations symmetrical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants