> I did the following check (in ghci):
>
> Prelude> let check a b = (a`div`b,a ==
> (a`div`b)*b+(a`mod`b) && ((a`mod`b)>=0) && ((a`mod`b)<b))
> Prelude> check 1 2
> (0,True)
> Prelude> check (-1) 2
> (-1,True)
>
> Thus, for positive divisors it seems OK.
> However the result for negative divisors I don't understand:
>
> Prelude> check 1 (-2)
> (-1,False)
> Prelude> check (-1) (-2)
> (0,False)
As I understand it, the condition (a`mod`b) >= 0 isn't necessarily true.
This condition is true, however:
let check a b = let (d,m) = divMod a b in
(d, m, a == d * b + m && abs m < abs b && signum m == signum b)
Cheers,
Simon
_______________________________________________
Hugs-Bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/hugs-bugs