Number Systems & Binary Arithmetic
Number Systems & Binary Arithmetic
Computers operate in binary (base 2). Understanding number system conversions and binary arithmetic is essential for computer engineering.
A number in base $b$:
$$(d_n d_{n-1} \dots d_1 d_0)_b = d_n b^n + d_{n-1} b^{n-1} + \cdots + d_1 b + d_0$$
| Base | Name | Digits |
|---|---|---|
| 2 | Binary | 0, 1 |
| 8 | Octal | 0–7 |
| 10 | Decimal | 0–9 |
| 16 | Hexadecimal | 0–9, A–F |
Convert $(1101\,0110)_2$ to decimal.
$1(128) + 1(64) + 0(32) + 1(16) + 0(8) + 1(4) + 1(2) + 0(1) = 128 + 64 + 16 + 4 + 2 = 214$
Convert decimal 200 to binary.
$200 ÷ 2 = 100$ R $0$
$100 ÷ 2 = 50$ R $0$
$50 ÷ 2 = 25$ R $0$
$25 ÷ 2 = 12$ R $1$
$12 ÷ 2 = 6$ R $0$
$6 ÷ 2 = 3$ R $0$
$3 ÷ 2 = 1$ R $1$
$1 ÷ 2 = 0$ R $1$
Read remainders bottom-up: $(1100\,1000)_2$
Add $(1011)_2 + (0111)_2$ in binary.
\begin{align}1011& \\ +\;0111& \\ \hline 10010&\end{align}
Result: $(10010)_2 = 18$ in decimal. Check: $11 + 7 = 18$ ✓
Practice Problems
Show Answer Key
1. $128+32+16+4+1 = 181$
2. $(11111111)_2$
3. $156 = 9 \times 16 + 12$; $(\text{9C})_{16}$
4. $3 \times 16 + 15 = 63$
5. $3 = 0011$, $F = 1111$; $(00111111)_2$
6. $(10110)_2 = 22$
7. $(0111)_2 = 7$
8. $(1111)_2 = 15$; check: $5 \times 3 = 15$ ✓
9. $3(64) + 4(8) + 7 = 192 + 32 + 7 = 231$
10. $2^8 = 256$ values; max $= 255$
11. $5 = 00000101$; invert: $11111010$; add 1: $11111011$
12. $-128$ to $+127$