Re: [racket] Rounding

2013-03-18 Thread Matthew Flatt
But Python 3 switched to round-to-even, FWIW. At Mon, 18 Mar 2013 06:49:28 -0500, Robby Findler wrote: > FWIW: it appears that both ruby and python round n.5 to n+1. > > Robby > > > On Sun, Mar 17, 2013 at 11:00 PM, Neil Toronto wrote: > > > On 03/16/2013 08:47 PM, Eric Nadeau wrote: > > > >>

Re: [racket] Rounding

2013-03-18 Thread Robby Findler
FWIW: it appears that both ruby and python round n.5 to n+1. Robby On Sun, Mar 17, 2013 at 11:00 PM, Neil Toronto wrote: > On 03/16/2013 08:47 PM, Eric Nadeau wrote: > >> I'm ditching Scheme altogether based on this... >> > > In case you're not trolling: changing languages won't help. This is >

Re: [racket] Rounding

2013-03-17 Thread Neil Toronto
On 03/16/2013 08:47 PM, Eric Nadeau wrote: I'm ditching Scheme altogether based on this... In case you're not trolling: changing languages won't help. This is standard behavior. And for goodness sake, you can always write your own function! Neil ⊥ Racket Users list:

Re: [racket] Rounding

2013-03-17 Thread Stephen Bloch
On Mar 16, 2013, at 11:47 PM, Eric Nadeau wrote: > The point of rounding is coming up with the best possible integer > approximation for a decimal and this nearest even number rule does not > qualify. Why not? In these cases there is no "the" best possible integer approximation, but two equ

Re: [racket] Rounding

2013-03-17 Thread Danny Yoo
> The point of rounding is coming up with the best possible integer > approximation for a decimal and this nearest even number rule does not > qualify. This "logic" was used by my grandparents' generation because odd > numbers were seen as less pure than even ones. This is a strawman argument.

Re: [racket] Rounding

2013-03-17 Thread Robby Findler
Racket is not Scheme. Please do not let our decisions influence your opinion of other languages. Go try Scheme for real. Robby On Sat, Mar 16, 2013 at 10:47 PM, Eric Nadeau wrote: > > The point of rounding is coming up with the best possible integer > approximation for a decimal and this near

Re: [racket] Rounding

2013-03-17 Thread Eric Nadeau
The point of rounding is coming up with the best possible integer approximation for a decimal and this nearest even number rule does not qualify. This "logic" was used by my grandparents' generation because odd numbers were seen as less pure than even ones. I'm ditching Scheme altogether based

Re: [racket] Rounding

2013-03-16 Thread Neil Toronto
On 03/16/2013 05:33 PM, Danny Yoo wrote: Since when is round 0.5 not giving 1?! According to the documentation: http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._round%29%29 "Returns the integer closest to x, resolving ties in favor o

Re: [racket] Rounding

2013-03-16 Thread Eli Barzilay
40 minutes ago, Carl Eastlund wrote: > That's an overly specific solution.  I believe the more general rounding > function taught in grade-school math would be: > > (define (my-round n) >   (floor (+ n 1/2))) If you want 0.5 to round down to 0, then (define (my-round n) (ceiling (- n 1/2))) -

Re: [racket] Rounding

2013-03-16 Thread mike
On Sat, Mar 16, 2013 at 10:21:57AM -0400, Eric Nadeau wrote: > Since when is round 0.5 not giving 1?! I believe that this is standard in physics and engineering in order to avoid statistical bias. For example, see the NIST "Guide for the Use of the International System of Units", section B.7. (

Re: [racket] Rounding

2013-03-16 Thread Carl Eastlund
That's an overly specific solution. I believe the more general rounding function taught in grade-school math would be: (define (my-round n) (floor (+ n 1/2))) This is also untested. And it might need tweaking for negative numbers if they are supposed to round away from zero, I forget how that

Re: [racket] Rounding

2013-03-16 Thread Danny Yoo
> > Since when is round 0.5 not giving 1?! According to the documentation: http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._round%29%29 "Returns the integer closest to x, resolving ties in favor of an even number... " And zero is an even

Re: [racket] Rounding

2013-03-16 Thread Eric Dobson
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#Ro

Re: [racket] Rounding

2013-03-16 Thread Nadeem Abdul Hamid
> Since when is round 0.5 not giving 1?! http://en.wikipedia.org/wiki/Rounding#Round_half_to_even --- nadeem Racket Users list: http://lists.racket-lang.org/users

[racket] Rounding

2013-03-16 Thread Eric Nadeau
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 ___