exact-integer-sqrt should continue the babylonian method in scheme.

The estimate given by the C code could be off by a large margin when
the result is inexact, converging far too slowly if we use simple
increments in Scheme.
This commit is contained in:
Alex Shinn 2013-04-14 04:59:49 +00:00
parent 83f8cfd69b
commit f8a5f7e004

View file

@ -61,7 +61,7 @@
(let lp ((res (inexact->exact (truncate res))))
(let ((rem (- x (* res res))))
(if (negative? rem)
(lp (- res 1))
(lp (quotient (+ res (quotient x res)) 2))
(values res rem)))))))
;; Adapted from Bawden's algorithm.