* bignum->flonum now handles large floats properly by converting

them to +inf.0 and -inf.0.
This commit is contained in:
Abdulaziz Ghuloum 2007-06-12 02:25:13 +03:00
parent b01e289798
commit ca257870ce
2 changed files with 24 additions and 12 deletions

Binary file not shown.

View File

@ -91,8 +91,10 @@
; | | | | | | | ; | | | | | | |
; v0 v1 v2 v3 v4 v5 v6 v7 ; v0 v1 v2 v3 v4 v5 v6 v7
(define ($flonum pos? e f6 f5 f4 f3 f2 f1 f0) (define ($flonum pos? e f6 f5 f4 f3 f2 f1 f0)
(let ([v ($make-flonum)])
(let ([be (fx+ e 1075)]) (let ([be (fx+ e 1075)])
(let ([v ($make-flonum)])
(cond
[(fx< be 2047)
(let ([sbe (if pos? be (fxlogor be (fxsll 1 11)))]) (let ([sbe (if pos? be (fxlogor be (fxsll 1 11)))])
($flonum-set! v 0 (fxsra sbe 4)) ($flonum-set! v 0 (fxsra sbe 4))
($flonum-set! v 1 (fxlogor (fxsll sbe 4) (fxlogand f6 #b1111))) ($flonum-set! v 1 (fxlogor (fxsll sbe 4) (fxlogand f6 #b1111)))
@ -101,8 +103,18 @@
($flonum-set! v 4 f3) ($flonum-set! v 4 f3)
($flonum-set! v 5 f2) ($flonum-set! v 5 f2)
($flonum-set! v 6 f1) ($flonum-set! v 6 f1)
($flonum-set! v 7 f0))) ($flonum-set! v 7 f0))]
v)) [else ;;; inf
(let ([sbe (if pos? 2047 (fxlogor 2047 (fxsll 1 11)))])
($flonum-set! v 0 (fxsra sbe 4))
($flonum-set! v 1 (fxsll sbe 4))
($flonum-set! v 2 0)
($flonum-set! v 3 0)
($flonum-set! v 4 0)
($flonum-set! v 5 0)
($flonum-set! v 6 0)
($flonum-set! v 7 0))])
v)))
(define ($flonum/c0 pos? e f6 f5 f4 f3 f2 f1 f0 c) (define ($flonum/c0 pos? e f6 f5 f4 f3 f2 f1 f0 c)
(define ($fxeven? x) (define ($fxeven? x)
(fxzero? (fxlogand x 1))) (fxzero? (fxlogand x 1)))