fixed error in division in (/ 0 <bignum>)

This commit is contained in:
Abdulaziz Ghuloum 2009-04-06 17:14:57 +03:00
parent 4ca8b1add2
commit 7d6316f723
2 changed files with 17 additions and 15 deletions

View File

@ -1233,20 +1233,22 @@
(binary- 0 (fxquotient x g))
(binary- 0 (fxquotient y g)))])))])]
[(bignum? y)
(let ([g (binary-gcd x y)])
(cond
[(= g y) (quotient x g)] ;;; should not happen
[($bignum-positive? y)
(if ($fx= g 1)
($make-ratnum x y)
($make-ratnum (fxquotient x g) (quotient y g)))]
[else
(if ($fx= g 1)
($make-ratnum (binary- 0 x) (binary- 0 y))
($make-ratnum
(binary- 0 (fxquotient x g))
(binary- 0 (quotient y g))))]))]
[(ratnum? y)
(if ($fx= x 0)
0
(let ([g (binary-gcd x y)])
(cond
[(= g y) (quotient x g)]
[($bignum-positive? y)
(if ($fx= g 1)
($make-ratnum x y)
($make-ratnum (fxquotient x g) (quotient y g)))]
[else
(if ($fx= g 1)
($make-ratnum (binary- 0 x) (binary- 0 y))
($make-ratnum
(binary- 0 (fxquotient x g))
(binary- 0 (quotient y g))))])))]
[(ratnum? y)
(/ (* x ($ratnum-d y)) ($ratnum-n y))]
[(or (compnum? y) (cflonum? y)) (x/compy x y)]
[else (err '/ y)])]

View File

@ -1 +1 @@
1753
1754