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

Incorrect hardcoded value of 0x8 in sqrtu function (should be 0x4) #22

Closed
nonergodic opened this issue Jun 24, 2022 · 1 comment
Closed

Comments

@nonergodic
Copy link

The hardcoded value here is wrong.

0x8 = 1<<3 but it should be 1<<2 i.e. 0x4

I'm not sure how smart solc is (whether it will unroll loops if one cranks the optimization runs sufficiently high - I haven't tried it yet), but all of this could be avoided by

using the 1 << shift syntax
writing the entire thing as a loop (same with the 7x code repetition below)
@cleanunicorn
Copy link

@nonergodic Can you provide an input and an expected output for which the hardcoded value would create problems?

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

3 participants