Converting number bases
Computer number system: base 2 (binary)
Base (radix) k = 2, digits di = (0, 1)
Given: 13ten
Find: binary representation
b5 b4 b3 b2 b1 b0
weight 25 24 23 22 21 20
digit 0 0 1 1 0 1 8 + 4 + 1 = 13ten
result remainder try it!
start 13
13/2 6 1 b0
6/2 3 0 b1
3/2 1 1 b2
1/2 0 1 b3
0/2 0 0 b4
0/2 0 0 b5
Why does this work?
13ten  =             b5 * 32 + b4 * 16 + b3 * 8 + b2 * 4 + b1 * 2 + b0
(2 * 6 + 1)ten  =      2 * (b5 * 16 + b4 *  8 + b3 * 4 + b2 * 2 + b1) + b0
Therefore, dividing by 2 gives a result of the expression in parentheses and a remainder of b0
6ten  =        b5 * 16 + b4 * 8 + b3 * 4 + b2 * 2 + b1
 = 2 * (b5 * 8 + b4 * 4 + b3 * 2 + b2) + b1
Dividing by 2 again gives a remainder of b1 and so forth.
3ten  =      b5 * 8 + b4 * 4 + b3 * 2 + b2
 = 2 * (b5 * 4 + b4 * 2 + b3) + b2
1ten  =      b5 * 4 + b4 * 2 + b3
 = 2 * (b5 * 2 + b4) + b3
0ten  = b5 * 2 + b4
What do all higher bits have to be?