[Haskell-cafe] C's fmod in Haskell

Henning Thielemann lemming at henning-thielemann.de
Tue Sep 25 04:58:54 EDT 2007

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 that the result of fmod(x,y) should have the same sign as x.
>> Interesting.
> 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).

Why is this particular behaviour useful in connection with trigonometric 

More information about the Haskell-Cafe mailing list