Skip to content

Commit 4224a1a

Browse files
onybhwwhww
authored andcommitted
Move comment on precision for computing square root to docstring
1 parent 94fb442 commit 4224a1a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

eth/_utils/numeric.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def clamp(inclusive_lower_bound: int,
105105
def integer_squareroot(value: int) -> int:
106106
"""
107107
Return the integer square root of ``value``.
108+
109+
Uses Python's decimal module to compute the square root of ``value`` with
110+
a precision of 128-bits. The value 128 is chosen since the largest square
111+
root of a 256-bit integer is a 128-bit integer.
108112
"""
109113
if not isinstance(value, int) or isinstance(value, bool):
110114
raise ValueError(
@@ -120,7 +124,5 @@ def integer_squareroot(value: int) -> int:
120124
)
121125

122126
with decimal.localcontext() as ctx:
123-
# Set precision to 128, since the largest square root of a
124-
# 256-bit integer is a 128-bit integer.
125127
ctx.prec = 128
126128
return int(decimal.Decimal(value).sqrt())

0 commit comments

Comments
 (0)