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

2008-10-31 Thread Sterling Clover
On Oct 30, 2008, at 5:21 PM, Bertram Felgenhauer wrote: George Pollard wrote: There's also the ieee-utils package, which provides an IEEE monad with `setRound`: http://hackage.haskell.org/packages/archive/ieee-utils/0.4.0/doc/ html/Numeric-IEEE-RoundMode.html When run with +RTS -N2 -R

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

2008-10-30 Thread Bertram Felgenhauer
George Pollard wrote: > There's also the ieee-utils package, which provides an IEEE monad with > `setRound`: > > http://hackage.haskell.org/packages/archive/ieee-utils/0.4.0/doc/html/Numeric-IEEE-RoundMode.html Hmm, this does not work well with the threaded RTS: > import Numeric.IEEE.Monad > imp

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

2008-10-28 Thread George Pollard
There's also the ieee-utils package, which provides an IEEE monad with `setRound`: http://hackage.haskell.org/packages/archive/ieee-utils/0.4.0/doc/html/Numeric-IEEE-RoundMode.html signature.asc Description: This is a digitally signed message part ___

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

2008-10-28 Thread Richard O'Keefe
Let me offer another suggestion which I think can be fitted into Haskell quite well. For the applications of rounding choice that I'm aware of, you want to choose when you write the code, not when you run it. This was actually reflected in the design of a real machine: the DEC Alpha. Floating p

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

2008-10-28 Thread Lennart Augustsson
I agree that the name is not the most descriptive one, and perhaps we should have the more descriptive ones. But when I hear "round", I assume it's the kind of rounding Haskell does. And I assumed this before Haskell came about. On Tue, Oct 28, 2008 at 6:07 PM, Bart Massey <[EMAIL PROTECTED]> wro

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

2008-10-28 Thread wren ng thornton
Bart Massey wrote: Peter Gavin gmail.com> writes: The reason for doing it this way is that e.g. 2.5 is exactly between 2 and 3, and rounding *up* every time would cause an uneven bias toward 3. To counteract that effect, rounding to the nearest even integer is used, which causes the half of th

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

2008-10-28 Thread David Roundy
On Tue, Oct 28, 2008 at 04:07:12PM +, Bart Massey wrote: > I'm just saying that the name "round" is unfortunate, since > there's no single universally accepted mathematical > definition for it. For this reason many programming > languages either don't provide it or provide a different > version

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

2008-10-28 Thread Bart Massey
Lennart Augustsson augustsson.net> writes: > On Mon, Oct 27 2008, Bart Massey cs.pdx.edu> wrote: > > I think given that the Haskell 98 Report is pretty > > explicit about the behavior of round, we're stuck with > > it, but I don't like it. It's yet another tiny > > impediment to Haskell newbies,

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

2008-10-28 Thread Felipe Lessa
On Mon, Oct 27, 2008 at 6:15 PM, Bart Massey <[EMAIL PROTECTED]> wrote: > BTW, in case anyone is unclear, IEEE 854 supports a large > variety of required and optional rounding modes; it takes no > strong position on a "correct" rounding strategy. In > particular, round-up ("round-half-up") and roun

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

2008-10-28 Thread Lennart Augustsson
You're assuming newbies from a bad educational system that hasn't taught them how to round properly. :) -- Lennart On Mon, Oct 27, 2008 at 10:15 PM, Bart Massey <[EMAIL PROTECTED]> wrote: > I think given that the Haskell 98 Report is pretty explicit > about the behavior of round, we're stuck wi

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

2008-10-27 Thread Achim Schneider
Daniel Fischer <[EMAIL PROTECTED]> wrote: > Am Montag, 27. Oktober 2008 13:34 schrieb Achim Schneider: > > > > > > Who does such horrible things? > > > Repeat after me: 1 is NOT a prime. Never, under no circumstances. > > > > Then chase it out of your prime factor products. You'd be the first > >

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

2008-10-27 Thread Aaron Denney
On 2008-10-27, Bart Massey <[EMAIL PROTECTED]> wrote: > Peter Gavin gmail.com> writes: >> The reason for doing it this way is that e.g. 2.5 is >> exactly between 2 and 3, and rounding *up* every time >> would cause an uneven bias toward 3. To counteract that >> effect, rounding to the nearest eve

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

2008-10-27 Thread Bart Massey
Peter Gavin gmail.com> writes: > The reason for doing it this way is that e.g. 2.5 is > exactly between 2 and 3, and rounding *up* every time > would cause an uneven bias toward 3. To counteract that > effect, rounding to the nearest even integer is used, > which causes the half of the x.5 values

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

2008-10-27 Thread ajb
G'day all. Quoting Daniel Fischer <[EMAIL PROTECTED]>: Who does such horrible things? Repeat after me: 1 is NOT a prime. Never, under no circumstances. The definition of "prime" is well-understood standard terminology, but that doesn't escape the fact that it's arbitrary and human-defined. I

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

2008-10-27 Thread Stefan Monnier
>>> 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 ;-) I think it has a name... "modulo" maybe? Stefan ___ Haskell-Cafe m

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

2008-10-27 Thread Lennart Augustsson
But you shouldn't use the "common round function", you should use the Haskell round function. That's the one that is mathematically better and has hardware support. On Mon, Oct 27, 2008 at 2:05 PM, L.Guo <[EMAIL PROTECTED]> wrote: > Thank you all for instructions. > > I am not the same education r

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

2008-10-27 Thread Daniel Fischer
Am Montag, 27. Oktober 2008 13:34 schrieb Achim Schneider: > > > > Who does such horrible things? > > Repeat after me: 1 is NOT a prime. Never, under no circumstances. > > Then chase it out of your prime factor products. You'd be the first one > to break a monoid and locate unsafeCalculate#. Huh?

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

2008-10-27 Thread Achim Schneider
"Felipe Lessa" <[EMAIL PROTECTED]> wrote: > On Mon, Oct 27, 2008 at 10:20 AM, Achim Schneider <[EMAIL PROTECTED]> > wrote: > > Hmmm... I'm wondering whether there's a standard C way to set the > > rounding direction. > > nearbyint() and rint() may be used, and the rounding mode can be set > by fe

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

2008-10-27 Thread Achim Schneider
Daniel Fischer <[EMAIL PROTECTED]> wrote: > Am Montag, 27. Oktober 2008 12:35 schrieb Achim Schneider: > > Daniel Fischer <[EMAIL PROTECTED]> wrote: > > > Am Montag, 27. Oktober 2008 11:46 schrieb Henning Thielemann: > > > > I also know a didact which tells teachers that 1 has no prime > > > > dec

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

2008-10-27 Thread Felipe Lessa
On Mon, Oct 27, 2008 at 10:20 AM, Achim Schneider <[EMAIL PROTECTED]> wrote: > Hmmm... I'm wondering whether there's a standard C way to set the > rounding direction. nearbyint() and rint() may be used, and the rounding mode can be set by fesetround(). IIRC, this is C99. -- Felipe. _

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

2008-10-27 Thread Achim Schneider
Henning Thielemann <[EMAIL PROTECTED]> wrote: > > On Mon, 27 Oct 2008, L.Guo wrote: > > > And then, in haskell, is that means, I have to use 'floor . (.5+)' > > instead of 'round' to get the common round function ? > > That's certainly the best to do. > Hmmm... I'm wondering whether there's a

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

2008-10-27 Thread Henning Thielemann
On Mon, 27 Oct 2008, L.Guo wrote: And then, in haskell, is that means, I have to use 'floor . (.5+)' instead of 'round' to get the common round function ? That's certainly the best to do. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http:/

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

2008-10-27 Thread L.Guo
Thank you all for instructions. I am not the same education route with you, so i just heard round-to-even for the very first time. Now I understand why it exists in theory. And then, in haskell, is that means, I have to use 'floor . (.5+)' instead of 'round' to get the common round function ?

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

2008-10-27 Thread Daniel Fischer
Am Montag, 27. Oktober 2008 12:35 schrieb Achim Schneider: > Daniel Fischer <[EMAIL PROTECTED]> wrote: > > Am Montag, 27. Oktober 2008 11:46 schrieb Henning Thielemann: > > > I also know a didact which tells teachers that 1 has no prime > > > decomposition. Oh, I see, she may have copied that from

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

2008-10-27 Thread Achim Schneider
Daniel Fischer <[EMAIL PROTECTED]> wrote: > Am Montag, 27. Oktober 2008 11:46 schrieb Henning Thielemann: > > > I also know a didact which tells teachers that 1 has no prime > > decomposition. Oh, I see, she may have copied that from Wikipedia: > > http://en.wikipedia.org/wiki/Prime_factorisat

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

2008-10-27 Thread Achim Schneider
"L.Guo" <[EMAIL PROTECTED]> wrote: > "round x returns the nearest integer to x, the even integer if x is > equidistant between two integers." > > > Is there any explanation about that ? > Yes. math.h, rint() and IEEE. The Right Way(tm) to round is rounding every other n.5 into a different dire