File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ def clamp(inclusive_lower_bound: int,
105
105
def integer_squareroot (value : int ) -> int :
106
106
"""
107
107
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.
108
112
"""
109
113
if not isinstance (value , int ) or isinstance (value , bool ):
110
114
raise ValueError (
@@ -120,7 +124,5 @@ def integer_squareroot(value: int) -> int:
120
124
)
121
125
122
126
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.
125
127
ctx .prec = 128
126
128
return int (decimal .Decimal (value ).sqrt ())
You can’t perform that action at this time.
0 commit comments