Re: [Haskell-cafe] C's fmod in Haskell

2007-09-26 Thread Henning Thielemann
On Wed, 26 Sep 2007, ok wrote: [Concerning the fact that fmod(x,y) = -fmod(-x,y)] I wrote: Interesting, perhaps. Surprising, no. fmod() is basically there for the sake of sin(), cos(), and tan() (or any other periodic and either symmetric or antisymmetric function). On 25 Sep 2007, at

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-25 Thread Henning Thielemann
On Tue, 25 Sep 2007, ok wrote: On 25 Sep 2007, at 10:55 am, Thomas Conway wrote: This old chestnut! It's a common problem in practice. As I recall, the behaviour of C's % operator allows implementations to yield either behaviour. I just checked ISO 9899:1999 which defines fmod. It specifies

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-25 Thread ok
[Concerning the fact that fmod(x,y) = -fmod(-x,y)] I wrote: Interesting, perhaps. Surprising, no. fmod() is basically there for the sake of sin(), cos(), and tan() (or any other periodic and either symmetric or antisymmetric function). On 25 Sep 2007, at 8:58 pm, Henning Thielemann wrote:

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-24 Thread Henning Thielemann
On Sun, 23 Sep 2007, Thomas Conway wrote: In Prelude there is a function properFraction which splits a RealFrac into its integer part and its fractional part. You can use this to implement fmod. Assuming properFraction is efficient (which it probably isn't), you can implement fmod really quite

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-24 Thread Thomas Conway
On 9/24/07, Henning Thielemann [EMAIL PROTECTED] wrote: Unfortunately, properFraction doesn't work well with negative numbers. This old chestnut! It's a common problem in practice. As I recall, the behaviour of C's % operator allows implementations to yield either behaviour. I just checked ISO

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-24 Thread ok
On 25 Sep 2007, at 10:55 am, Thomas Conway wrote: This old chestnut! It's a common problem in practice. As I recall, the behaviour of C's % operator allows implementations to yield either behaviour. I just checked ISO 9899:1999 which defines fmod. It specifies that the result of fmod(x,y)

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-23 Thread Thomas Conway
On 9/17/07, Peter Verswyvelen [EMAIL PROTECTED] wrote: Maybe this is a stupid question, but I don't find something similar in Haskell. I find mod and rem, which work on integers. But I'm looking for a function similar to C's fmod. Of course I can write it myself, but I guess it must

[Haskell-cafe] C's fmod in Haskell

2007-09-17 Thread Peter Verswyvelen
Maybe this is a stupid question, but I don't find something similar in Haskell. I find mod and rem, which work on integers. But I'm looking for a function similar to C's fmod. Of course I can write it myself, but I guess it must already exist under a different name? Thanks, Peter

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-17 Thread Jules Bean
Peter Verswyvelen wrote: Maybe this is a stupid question, but I don't find something similar in Haskell. I find mod and rem, which work on integers. But I'm looking for a function similar to C's fmod. Of course I can write it myself, but I guess it must already exist under a different

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-17 Thread Peter Verswyvelen
Odd place it is, indeed! QUOTE: Data.Fixed... DESCRIPTION... This module defines a Fixed file:///D:/app/ghc-6.6.1/doc/html/libraries/base/Fixed.html type for fixed-precision arithmetic...*This module also contains generalisations of div, mod, and divmod to work with any Real instance.*