Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Richard O'Keefe
On 28 Oct 2008, at 11:11 am, Henning Thielemann wrote: In measured data the .5-case should be very rare - a "null set"? However I assume that .5 happens more often in practice - because of prior rounding, Think about money. When I was a child, farthings (1/4 of a penny) had just been dropped

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Richard O'Keefe
On 27 Oct 2008, at 11:00 pm, Henning Thielemann wrote: On Mon, 27 Oct 2008, L.Guo wrote: I think this is unresonable. then try it in GHC 6.8.3. Prelude> round 3.5 4 Prelude> round 2.5 2 Is there any explanation about that ? It's the definition we learnt in school ... Check http://en

RE: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread ajb
G'day all. Henning Thielemann suggested: In measured data the .5-case should be very rare - a "null set"? However I assume that .5 happens more often in practice - because of prior rounding, which was shown to be bad practice in this thread. The usual case in floating point is usually not

RE: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread ajb
G'day all. Quoting "Mitchell, Neil" <[EMAIL PROTECTED]>: With rounding to the nearest even integer for 0.5's you get 6, otherwise if you always round up you get 7. If you bias towards rounding up you get a general upwards trend as numbers are rounded, which is bad, while the even condition ensu

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, Janis Voigtlaender wrote: Lennart Augustsson wrote: I can't remember the method being called anything. It was just what we were being taught. With the obvious explanation that .5 is right in the middle so always going one way would introduce a bias. This was circa 1969.

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, Ketil Malde wrote: Of course, Haskell should discard the rather tasteless IEEE754 crud, and do its calculations on infinite streams of digits. Then, rounding upwards after 'take'ing a sufficient amount of decimals will be the right thing to do. When I implemented just th

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Peter Gavin
L.Guo wrote: Hi all: I just read about definitions of Prelude [1], and noticing that. In 6.4.6 Coercions and Component Extraction, it discribes like this: "round x returns the nearest integer to x, the even integer if x is equidistant between two integers." I think this is unresonable. th

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread John A. De Goes
It's well known from numerical analysis that you can achieve the best general behavior by rounding to even in "half" the cases, and rounding to odd in "half" the cases. It's usually deterministic by looking at the digit to the right of the round point. Regards, John A. De Goes N-BRAIN, I

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Martijn van Steenbergen
Ketil Malde wrote: Of course, Haskell should discard the rather tasteless IEEE754 crud, and do its calculations on infinite streams of digits. Then, rounding upwards after 'take'ing a sufficient amount of decimals will be the right thing to do. Except arbitrary-precision real arithmetic is not

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Jules Bean
This behaviour is not what I expect after reading the description at http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:round . Given that this behaviour has caused a bit of confusion I think a change to the documention might be in order. The authority here is the report whic

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Ketil Malde wrote: Janis Voigtlaender <[EMAIL PROTECTED]> writes: Since just about every floating point operation involves some sort of loss of precision, repeated rounding is a fact of life. Of course. But that was not the point of the discussion... Well, allow me to contribute to kee

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Ketil Malde
Janis Voigtlaender <[EMAIL PROTECTED]> writes: >> Since just about every floating point operation involves some sort of >> loss of precision, repeated rounding is a fact of life. > Of course. But that was not the point of the discussion... Well, allow me to contribute to keeping the discussion

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Brandon S. Allbery KF8NH
On 2008 Oct 27, at 6:00, Henning Thielemann wrote: On Mon, 27 Oct 2008, L.Guo wrote: I think this is unresonable. then try it in GHC 6.8.3. Prelude> round 3.5 4 Prelude> round 2.5 2 Is there any explanation about that ? It's the definition we learnt in school ... Maybe you did; I learned "

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Thomas Davie
[1] The Haskell 98 Report: Predefined Types and Classes http://haskell.org/onlinereport/basic.html This behaviour is not what I expect after reading the description at http://haskell.org/ghc/docs/latest/html/libraries/base/ Prelude.html#v:round . Given that this behaviour has caused a bit o

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Magnus Therning
On Mon, Oct 27, 2008 at 1:37 PM, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > I can't remember the method being called anything. > It was just what we were being taught. With the obvious explanation > that .5 is right in the middle so always going one way would introduce > a bias. This was cir

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Magnus Therning
On Mon, Oct 27, 2008 at 9:48 AM, L.Guo <[EMAIL PROTECTED]> wrote: > Hi all: > > > I just read about definitions of Prelude [1], and noticing that. > > In 6.4.6 Coercions and Component Extraction, it discribes like this: > > > "round x returns the nearest integer to x, the even integer if x is > eq

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Lennart Augustsson wrote: I can't remember the method being called anything. It was just what we were being taught. With the obvious explanation that .5 is right in the middle so always going one way would introduce a bias. This was circa 1969. Well, I wasn't serious about the "political" exp

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Lennart Augustsson
I can't remember the method being called anything. It was just what we were being taught. With the obvious explanation that .5 is right in the middle so always going one way would introduce a bias. This was circa 1969. On Mon, Oct 27, 2008 at 3:30 PM, Janis Voigtlaender <[EMAIL PROTECTED]> wrot

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Lennart Augustsson wrote: It is certainly what I learnt in school. But that was another school. Hmm, on reflection, taking Neil's explanation into account and the fact that this rounding mode was referred to as "banker's rounding", the point may be that it was not only another school, but anot

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Lennart Augustsson
It is certainly what I learnt in school. But that was another school. On Mon, Oct 27, 2008 at 12:15 PM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: > Henning Thielemann wrote: >> >> On Mon, 27 Oct 2008, L.Guo wrote: >> >>> I think this is unresonable. then try it in GHC 6.8.3. >>> >>> >>> Prelu

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Magnus Therning
2008/10/27 Janis Voigtlaender <[EMAIL PROTECTED]>: > Janis Voigtlaender wrote: > >> 2.4x -> x > > That's supposed to be 2.4x -> 2, of course. Ah, damn it. I was hoping for a long discussion on just what math would look like with rounding like that ;-) /M -- Magnus Therning

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Ketil Malde wrote: Janis Voigtlaender <[EMAIL PROTECTED]> writes: If you round to odd instead of round to even, then 4.5 rounds to 5, Well, of course I did not learn to round to odd. I learned to round .5 to above, but not to do repeated rounding. Since just about every floating point o

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, Daniel Fischer wrote: Am Montag, 27. Oktober 2008 11:46 schrieb Henning Thielemann: On Mon, 27 Oct 2008, Janis Voigtlaender wrote: Henning Thielemann wrote: I think one reason is that repeated rounding should not be worse than rounding in one go. Consider the rule 'use c

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Daniel Fischer
Am Montag, 27. Oktober 2008 11:46 schrieb Henning Thielemann: > On Mon, 27 Oct 2008, Janis Voigtlaender wrote: > > Henning Thielemann wrote: > >> I think one reason is that repeated rounding should not be worse than > >> rounding in one go. Consider the rule 'use ceiling when the first > >> removed

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Ketil Malde
Janis Voigtlaender <[EMAIL PROTECTED]> writes: >> If you round to odd instead of round to even, then 4.5 rounds to 5, > Well, of course I did not learn to round to odd. I learned to round .5 > to above, but not to do repeated rounding. Since just about every floating point operation involves som

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, Janis Voigtlaender wrote: Henning Thielemann wrote: I think one reason is that repeated rounding should not be worse than rounding in one go. Consider the rule 'use ceiling when the first removed digit is 5'. Then 0.45 - (round to one place) -> 0.5 - (round to integer)

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Felipe Lessa wrote: On Mon, Oct 27, 2008 at 8:30 AM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: Well, of course I did not learn to round to odd. I learned to round .5 to above, but not to do repeated rounding. Nobody rounds in passes, of course =). Oh, Mrs. "I forgot her name" actually

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Henning Thielemann wrote: I think one reason is that repeated rounding should not be worse than rounding in one go. Consider the rule 'use ceiling when the first removed digit is 5'. Then 0.45 - (round to one place) -> 0.5 - (round to integer) -> 1 But repeated rounding *is* worse than round

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Felipe Lessa
On Mon, Oct 27, 2008 at 8:30 AM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: > Well, of course I did not learn to round to odd. I learned to round .5 > to above, but not to do repeated rounding. Nobody rounds in passes, of course =). I was talking about two successive rounds. > In fact, by your

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Janis Voigtlaender wrote: 2.4x -> x That's supposed to be 2.4x -> 2, of course. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Felipe Lessa wrote: On Mon, Oct 27, 2008 at 8:15 AM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: That is of course true (and was the topic of heated discussion with my fourth grade math teacher), but does not explain 2.5 -> 2. If you round to odd instead of round to even, then 4.5 rounds t

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Felipe Lessa
(Janis, sorry for e-mailiing just for you on the first time.) On Mon, Oct 27, 2008 at 8:15 AM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: > That is of course true (and was the topic of heated discussion with my > fourth grade math teacher), but does not explain 2.5 -> 2. If you round to odd in

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, Janis Voigtlaender wrote: Henning Thielemann wrote: On Mon, 27 Oct 2008, L.Guo wrote: I think this is unresonable. then try it in GHC 6.8.3. Prelude> round 3.5 4 Prelude> round 2.5 2 Is there any explanation about that ? It's the definition we learnt in school ..

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Janis Voigtlaender
Henning Thielemann wrote: On Mon, 27 Oct 2008, L.Guo wrote: I think this is unresonable. then try it in GHC 6.8.3. Prelude> round 3.5 4 Prelude> round 2.5 2 Is there any explanation about that ? It's the definition we learnt in school ... Hmm, Henning, this is strange. The two of us w

RE: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Mitchell, Neil
> [mailto:[EMAIL PROTECTED] On Behalf Of L.Guo > Sent: 27 October 2008 9:49 am > To: MailList Haskell-Cafe > Subject: [Haskell-cafe] Why 'round' does not just round numbers ? > > Hi all: > > > I just read about definitions of Prelude [1], and noticing that. >

Re: [Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, L.Guo wrote: I think this is unresonable. then try it in GHC 6.8.3. Prelude> round 3.5 4 Prelude> round 2.5 2 Is there any explanation about that ? It's the definition we learnt in school ... I think one reason is that repeated rounding should not be worse than roun

[Haskell-cafe] Why 'round' does not just round numbers ?

2008-10-27 Thread L.Guo
Hi all: I just read about definitions of Prelude [1], and noticing that. In 6.4.6 Coercions and Component Extraction, it discribes like this: "round x returns the nearest integer to x, the even integer if x is equidistant between two integers." I think this is unresonable. then try it in GH