In the patterson's book (computer architecture: hardware/software interface) and for dividing signed numbers, it is stated that
Code:
This anomalous behavior is avoided by following the rule that the dividend and
remainder must have the same signs, no matter what the signs of the divisor and quotient.
We calculate the other combinations by following the same rule:
+7 / –2: Quotient = –3, Remainder = +1
Now if you use google to calculate (-1) mod 4, you will get +3 that means (this
link)
-1 = -1 * 4 + 3
which contradicts patterson's statement. I also see similar thing in the VHDL book (attachment)