We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
uint(-1)
The current implementation of sqrt, copied here for convenience:
1. function sqrt(uint y) internal pure returns (uint z) { 2. if (y > 3) { 3. uint x = (y + 1) / 2; 4. z = y; 5. while (x < z) { 6. z = x; 7. x = (y / x + x) / 2; 8. } 9. } else if (y != 0) { 10. z = 1; 11. } 12. }
reverts given the argument uint(-1), as this sets x to zero, leading to a division by zero error at line 7.
x
An easy fix is to change L3 to uint x = y / 2 + 1;, which makes the function well defined for uint(-1) as well.
uint x = y / 2 + 1;
The text was updated successfully, but these errors were encountered:
d1c8612
address uint(-1) failure case
32e9b5c
closes Uniswap#48
No branches or pull requests
The current implementation of sqrt, copied here for convenience:
reverts given the argument
uint(-1)
, as this setsx
to zero, leading to a division by zero error at line 7.An easy fix is to change L3 to
uint x = y / 2 + 1;
, which makes the function well defined foruint(-1)
as well.The text was updated successfully, but these errors were encountered: