* changed implemenation of flround.

This commit is contained in:
Abdulaziz Ghuloum 2007-11-13 03:10:39 -05:00
parent 3feb49e10c
commit 47f7016b18
2 changed files with 14 additions and 12 deletions

Binary file not shown.

View File

@ -2104,24 +2104,26 @@
(let ([n ($ratnum-n x)] [d ($ratnum-d x)])
(quotient n d)))
(define ($flround x)
($fl/ ($fl* x 5e-324) 5e-324))
(define (flround x)
;;; FIXME: flround should preserve the sign of -0.0.
(if (flonum? x)
(let ([e ($flonum->exact x)])
(cond
[(ratnum? e) (exact->inexact ($ratnum-round e))]
[else x]))
($flround x)
(error 'flround "not a flonum" x)))
;(define (flround x)
; ;;; FIXME: flround should preserve the sign of -0.0.
; (if (flonum? x)
; (let ([e ($flonum->exact x)])
; (cond
; [(ratnum? e) (exact->inexact ($ratnum-round e))]
; [else x]))
; (error 'flround "not a flonum" x)))
(define (round x)
;;; FIXME: flround should preserve the sign of -0.0.
(cond
[(flonum? x)
(let ([e (or ($flonum->exact x)
(error 'round "number has no real value" x))])
(cond
[(ratnum? e) (exact->inexact ($ratnum-round e))]
[else x]))]
[(flonum? x) ($flround x)]
[(ratnum? x) ($ratnum-round x)]
[(or (fixnum? x) (bignum? x)) x]
[else (error 'round "not a number" x)]))