mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 21:15:28 -05:00
Merge pull request #426 from jrhea/div_by_zero_fix
add assertion to integer_squareroot() to prevent negative results.
This commit is contained in:
@@ -1097,6 +1097,7 @@ def integer_squareroot(n: int) -> int:
|
||||
"""
|
||||
The largest integer ``x`` such that ``x**2`` is less than ``n``.
|
||||
"""
|
||||
assert n >= 0
|
||||
x = n
|
||||
y = (x + 1) // 2
|
||||
while y < x:
|
||||
|
||||
Reference in New Issue
Block a user