This is a 2 part question.
part 1 (negative mod calculations):
As part of a larger equation, I have come to a stage where I need to calculate -17 mod 11. By doing it manually I got -6 as the result. (-17 - ((-17 / 11) * 11))
But by checking an online mod calculator, the result is 5.
I don't understand. Can someone shed some light on the process of calculating negative mods?
part 2 (order of operations):
This also involves mod. I am wondering what order to calculate an equation which involves mod and multiplication.
for example: x (f - g) mod y
would you calculate x (f - g) first and then mod the result by y.
or (f - g) mod y first then the result * x?
Thank you for any help you can provide.
$$- 25 - \lfloor -25/11\rfloor \times 11 = - 25 - \lfloor−2.2727...\rfloor \times 11 = -25 -(-3)11 = -25 + 33 = 8$$
– gammatester Oct 16 '13 at 10:11