Fixes bug 180170: Missing bignum sqrt

This commit is contained in:
Abdulaziz Ghuloum 2008-01-04 21:46:50 -05:00
parent 3cd68e7ea3
commit af6562721b
2 changed files with 12 additions and 2 deletions

View File

@ -2065,7 +2065,17 @@
(cond (cond
[(flonum? x) (foreign-call "ikrt_fl_sqrt" x)] [(flonum? x) (foreign-call "ikrt_fl_sqrt" x)]
[(fixnum? x) (foreign-call "ikrt_fx_sqrt" x)] [(fixnum? x) (foreign-call "ikrt_fx_sqrt" x)]
[(bignum? x) (die 'sqrt "BUG: bignum sqrt not implemented")] [(bignum? x)
(unless ($bignum-positive? x)
(error 'sqrt "complex results not supported" x))
(let-values ([(s r) (exact-integer-sqrt x)])
(cond
[(eq? r 0) s]
[else
(let ([v (sqrt (inexact x))])
(cond
[(infinite? v) (inexact s)]
[else v]))]))]
[(ratnum? x) (/ (sqrt ($ratnum-n x)) (sqrt ($ratnum-d x)))] [(ratnum? x) (/ (sqrt ($ratnum-n x)) (sqrt ($ratnum-d x)))]
[else (die 'sqrt "BUG: unsupported" x)]))) [else (die 'sqrt "BUG: unsupported" x)])))

View File

@ -1 +1 @@
1328 1329