Given $a$ and $b$ are integers, can there exist a negative value for $a \pmod b$?
Asked
Active
Viewed 42 times
0
1 Answers
1
The Euclidian division theorem says that for any two integers $a,b\in \mathbb{Z}$ and $b\neq 0$, there exist unique integers $r,q\in\mathbb{Z}$ such that $a=bq+r$ and $0\leq r< |b|$. So if what you mean by $a\%b$ is calculating the residue of the division of $a$ and $b$, no, $r$ can not be negative.
If you meant that $a\% b$ is calculating $a$ mod$(b)$, then it can be negative, because the class of equivalence of $a$ in $\mathbb{Z}/b\mathbb{Z}$, $$[a]=\{\dots,a-2b,a-b,a,a+b,a+2b,\dots\}.$$
GSF
- 914
-
I would say, more precisely, that (in the second interpretation) saying "$a\pmod b$ is negative" is not a meaningful assertion, because some members of the equivalence class are negative and others are not. Similarly, it would make no sense to talk about whether $a\pmod 7$ is even or odd. Both are the mathematical equivalent of asking something like "Which country's people are named Lee?" – Greg Martin Feb 18 '17 at 13:24
-
Yes, that's true @GregMartin , I should have said that the class of $a$ admits a negative integer as a representative. – GSF Feb 18 '17 at 13:28
a % bhas the same sign as the dividendb(and can be negative). Here is an overview: https://en.wikipedia.org/wiki/Modulo_operation. – Martin R Feb 18 '17 at 12:58a % b(in some programming language) or about $a \pmod b$ (in the sense of modulo arithmetic). – Until that is clarified, the question is unclear. – Martin R Feb 18 '17 at 13:04