[racket] Rounding
The docs say that it is round to even, which is the standard for
floating point numbers [1]. You can write your own rounding operator
that rounds .5 up if need be.
;; Untested
(define (my-round n)
(let ((r (round n))) (if (= .5 (- n r)) (add1 r) r)))
[1] http://en.wikipedia.org/wiki/Rounding#Round_half_to_even
On Sat, Mar 16, 2013 at 7:21 AM, Eric Nadeau <nado18 at gmail.com> wrote:
> Hi,
>
> I was having problems with a mathematical application I'm writing and narrowed it down to:
>
> (round 0.5)
> (round (/ 1 2))
> (round 1.5)
> (round (/ 3 2))
>
> giving me
>
> 0.0
> 0
> 2.0
> 2
>
> Since when is round 0.5 not giving 1?!
>
> Cheers,
> Eric
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users