Finding $a$ in modular arithmetic while $a<0$ I'm having a problem understanding this equation in modular arithmetic I have tried searching the internet but I haven't found a solution, I hope you can help.
$a = k(26) + b\; \text{ for }a > 0\:$ 
(26 is just what he uses in the book as he is explaining the Caesar cipher)
The author then goes on to say that even if $a$ were negative, we could easily find a positive number $b$ in the set $\{1,2,\ldots,26\}$ such that $a$ is congruent to $b$ by dividing the positive number $-a$ by $26$, obtaining:
$-a = q(26) + r = (q+1)26 - (26-r),\quad            
q\ge 0, \enspace 0\le r<26$.
My question is: How did he get to that equation, I seem to have tried anything, it might be that I am really tired, but I have to know the answer before I sleep.
Thank you
 A: All he is saying is that if $a < 0$ is it possible to say
$a = 26k + b$ where $b = \{1,....., 26\}$.
He does:
$a < 0$ so $-a > 0$.  Then if you divide $-a$ by $26$ you we get a quotient $q$ and a remainder $r$ so that
$\frac {-a}{26} = q + \frac r{26}$ and 
$-a = 26q + r$ and $ 0 \le r < 26$.
Then $-a = 26(q+1) -26 + r = 26(q+1) - (26-r)$.  So $0 \le r < 26$ we have $0 < 26-r \le 26$ so if we let $b = 26-r \in \{1,..., 26\}$ and let $k = -q-1$ we get
$a = 26(-q-1) +(26-r) = 26k + b$.
It works.
If $a > 0$ then there is a $b \in \{1....26\}$ where $a \equiv b \pmod {26}$.
And if $a < 0$ then there is a $b \in \{1... 26\}$ where $a \equiv b\pmod {26}$.
And if $a = 0$ then $a \equiv 26\pmod{26}$.
....
It's not deep.
I'd have done it simply by saying.  "Just add or subtract $26$ until you get some between $1$ and $26$ inclusive".
====== old answer===
If $a > 0$ there is a $k$ and a $b > 0$ so that $a = 26k + b$. [The book seems to have established that.]
But what if $a < 0$.  Can we find a $k$ and $b > 0$ so that $a = 26k +b$.
Yes.
If $a < 0$ then $-a > 0$ and we can find $q$ and $r: 0 \le r < 26$ so that
$-a = 26q + r$ 
$= 26(q+1) - 26 + r$
$= 26(q+1) - (26-r)$ and note that $r < 26$ so $ 26 -r > 0$.
But then 
$a = 26(-q-1) + (26-r)$.
Let $k = -q-1$ and $b = 26-r$ and this works fine
$a = 26k + b$ where $b > 0$ even though $a < 0$.
[ I suppose for $a = 0$ the book uses $0 = 26(-1) + 26$? ]
[It's not entirely clear what the book is trying to show.]
A: We usually write
$$a = k(26) + b\; \text{ for }a > 0\:$$ as
$$a = 26 \cdot k + b\; \text{ for }a > 0\:$$  where $k$ is the quotient when divided by 26 and $b$ is the remainder.
Now look at 
$$-a = q(26) + r = (q+1)26 - (26-r),\quad            
q\ge 0, \enspace 0\le r<26.$$
it is used to find the representative of a negative $-a$ number
$$-a = 26\cdot q + r = 26 (q+1) - (26-r),\quad            
q\ge 0, \enspace 0\le r<26.$$
The trick is, add and subtract 26. Take the $\mod 26$ in the last equation. And, the shortest way is $26-a$ if $a < 26$.
