mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
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:
parent
83f8cfd69b
commit
f8a5f7e004
1 changed files with 1 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue