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 @@ -305,12 +305,14 @@ def _fail_neg(values, errmsg='negative value'):
305
305
yield x
306
306
307
307
def _isqrt_frac_rto (n : int , m : int ) -> float :
308
- 'Square root of n/m, rounded to the nearest integer using round-to-odd.'
308
+ """Square root of n/m, rounded to the nearest integer using round-to-odd."""
309
+ # Refernce: https://www.lri.fr/~melquion/doc/05-imacs17_1-expose.pdf
309
310
a = math .isqrt (n // m )
310
311
return a | (a * a * m != n )
311
312
312
313
def _sqrt_frac (n : int , m : int ) -> float :
313
- 'Square root of n/m as a float, correctly rounded.'
314
+ """Square root of n/m as a float, correctly rounded."""
315
+ # See algorithm sketch at: https://bugs.python.org/msg406911
314
316
# The constant 109 is: 3 + 2 * sys.float_info.mant_dig
315
317
q : int = (n .bit_length () - m .bit_length () - 109 ) // 2
316
318
if q >= 0 :
You can’t perform that action at this time.
0 commit comments