fix rationalize on inexact arguments

svn: r11215
This commit is contained in:
Matthew Flatt 2008-08-13 10:52:53 +00:00
parent 7b0676ac7d
commit 0715f3d7f9

View File

@ -42,7 +42,12 @@
(if (< lo-int hi-int) (if (< lo-int hi-int)
(add1 lo-int) (add1 lo-int)
(+ lo-int (+ lo-int
(/ (find-between (/ (- hi lo-int)) (/ (- lo lo-int)))))))))]) (/ (find-between (/ (- hi lo-int)) (/ (- lo lo-int)))))))))]
[do-find-between
(lambda (lo hi)
(cond
[(negative? lo) (- (find-between (- hi) (- lo)))]
[else (find-between lo hi)]))])
(lambda (x within) (lambda (x within)
(check x) (check within) (check x) (check within)
(let* ([delta (abs within)] (let* ([delta (abs within)]
@ -56,8 +61,9 @@
[(equal? delta +inf.0) 0.0] [(equal? delta +inf.0) 0.0]
[(not (= x x)) +nan.0] [(not (= x x)) +nan.0]
[(<= lo 0 hi) (if (exact? x) 0 0.0)] [(<= lo 0 hi) (if (exact? x) 0 0.0)]
[(negative? lo) (- (find-between (- hi) (- lo)))] [(or (inexact? lo) (inexact? hi))
[else (find-between lo hi)]))))) (exact->inexact (do-find-between (inexact->exact lo) (inexact->exact hi)))]
[else (do-find-between lo hi)])))))
;; ------------------------------------------------------------------------- ;; -------------------------------------------------------------------------