6 Jun
2002
6 Jun
'02
11:59 a.m.
Hi, >> div 1 (-2) Jurek> -1
div 1 2 Jurek> 0
this is no contradiction since integer division is not symmetric for positive and negative numbers. 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) 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) Cheers -- Christoph