Is this a division by modulo or what

terminology

What is the name for this operation? Is it division by modulo? I'm really confused.

Here results will be always from 0 to 7, whichever dividend is.
-1 % 8 = 7
-7 % 8 = 1
-8 % 8 = 0

If previous operation is a division by modulo, so how I should name this operation?

Here results will be from -7 to 7.
-1 % 8 = -1
-7 % 8 = -7
-8 % 8 = 0

I'm totally noob in math.

I'm asking this question, because, for example, in Python programming language % operator will work as in first example I've given. In C / C++ / C# % operator will work as in seconds example. This enraged me, when I was debugging my program; I've thought % operator in C will work exactly the same as in Python.

Best Answer

The two languages compute slightly different things with the $\%$ operator.

Python computes the mod of the given two numbers. This means that the output will always lie in the range$[0,n)$ where $n$ is the modulus.

C computes the remainder of the given two numbers after division. This tends to produce identical outputs as the modulo operator for positive inputs, but remainders can be negative when the number being divided is negative.

This is why you see a difference.

Related Question