What exactly is the difference between mod
and rem
in Haskell?
Both seems to give the same results
*Main> mod 2 3
2
*Main> rem 2 3
2
*Main> mod 10 5
0
*Main> rem 10 5
0
*Main> mod 1 0
*** Exception: divide by zero
*Main> rem 1 0
*** Exception: divide by zero
*Main> mod 1 (-1)
0
*Main> rem 1 (-1)
0
They're not the same when the second argument is negative:
2 `mod` (-3) == -1
2 `rem` (-3) == 2