[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nitpick with FLOOR etc.
| Date: Sun, 17 Jul 2005 22:59:12 -0700 (PDT)
| From: bear <bear@xxxxxxxxx>
|
| One thing that is clear from inspecting code that actually
| uses FLOOR, CEILING, etc, is that there is a very strong
| usage pattern; the procedure inexact->exact is almost ALWAYS
| called on the result.
Originally, I was going to propose changing ROUND, etc to return
exacts; but an inexact FLOOR was needed to avoid exact vs inexact
range problems in extending MODULO to the reals:
(define (modulo x1 x2)
(if (and (integer? x1) (integer? x2))
(integer-modulo x1 x2)
(- x1 (* x2 (floor (/ x1 x2))))))
| I think standard library macros ought to capture and standardize
| this usage.
|
| (xfloor x) <==> (inexact->exact (floor x))
| (xceiling x) <==> (inexact->exact (ceiling x)
| (xround x) <==> (inexact->exact (round x))
Why macros when procedures would be equivalent?
Also, is the prefixed `x' for exact; wouldn't `e' be more Schemely?