Observe carefully, it is as simple as that.
Your issue is as follows:-
Why -3%16 = 13?
Before starting my answer to your question, kindly observe the following as well.
2 > 0 | -2 -1 | -2 -2 | -2 = -2
2 > -3 | -2 Also notice that 0 is not taken into consideration as the quotient to -3 % 16 because it is trivial to any case in this particular.
Dividend = -3
Divisor = 16
Quotient = -1
Remainder = 13 ==> This is the answer to your issue.
Immediately, you are going to think how?
Explanation to your issue as per college mathematics, I hope you have knowledge on addition modulo and multiplication modulo:-
Your issue falls under multiplication modulo.
Analytical Answer based on the Conceptual Understanding:-
16)-03(-1
-16
Sign Convertion: (+)
------------------------------------
-03+16 = 13
------------------------------------
If you are interested and familiar in understanding mathematics conceptually, kindly refer the Degree Mathematics Text Book containing the concepts of Addition Modulo as well as Multiplication Modulo in Group Theory and Vector Theory.
In those textbooks, modulos look like these:-
A+kB
A-kB
A*kB
k is called the respective modulo ranges over Integer Set.
A and B are operands to perform the execution.
If you refer those books without fail then you have a basic knowledge of how to compute modulos mathematically.
Still you faced any issues feel free to comment on my answer.
>>> # ******************
>>> # Technical Answer:-
>>> # ******************
>>> x = -3
>>> x
-3
>>> y = 16
>>> y
16
>>> x % y
13
>>> # is same as follows:-
>>> z = x % y
>>> z
13
>>> # only the difference between the previous answer and this answer is as follows:-
>>> # if you use like x % y as the above, whenever you require the resultant value of this computation for further actions (if applicable), you must always perform this task. Otherwise, Python Interpreter raises either ValueError or NameError based on the context of the logical code.
>>> # if you use like z = x % y as the above, and you also require the computational value, then you just call the object z itself, automatically it gets the result of the operation x % y. Also you can reuse it any number of times.