Q:

Modulus of numbers for negative divisors

How does the Google calculator or the Wolfram calculator calculate the modulus of the numbers with negative divisors? 
For example: -4 % -3 = -1 and 4 % -3 = -2 
The same topic has been mentioned here too : http://in.mathworks.com/help/matlab/ref/mod.html#buksxvr under the heading Remainder after division for Negative divisor. 
Please explain the procedure in which the answer for such negative divisors can be reached at.
Thank you!

A:

The operator $\mod{}$ : You have the equality $x=a\pmod p \iff x=a\pmod {-p}$, indeed : $$x=a\pmod p \iff x = a +kp \iff x = a + (-k)(-p)=a\pmod {-p}$$
The software operator $\%$ : If you compute $x \% p$ with $p \geq 0$, it will return the smallest positive $a$ such as $x=a \pmod p$, but if you compute $x \% p$ with $p \le 0$ , it will return the biggest negative $a$ such as $x=a \pmod p$.
Finally : $$\forall p \geq 0,x \% (-p)=(x \% p )-p$$

