Module 14 min

Number Systems & Binary Arithmetic

The Four Number Systems

Pro Tip

Why This Matters — Every digital circuit - from a simple AND gate to a billion-transistor processor - processes information as 0s and 1s. Before understanding gates, flip-flops, or RTL, you must be fluent in the four number systems engineers use daily: Binary, Octal, Decimal, and Hexadecimal.

The Four Number Systems

SystemBaseDigits UsedWhere Used
Binary20, 1Inside every digital circuit - the language of logic
Octal80–7Compact notation for binary groups; Unix permissions
Decimal100–9Human-readable; used in specifications
Hexadecimal160–9, A–FMemory addresses, register values, color codes

Place Value - The Core Concept

Every number system works by assigning a positional weight to each digit. The rightmost digit has weight base0 = 1, the next has base1, then base2, and so on.

General Place Value Formula
Value = dn×Bn + dn-1×Bn-1 + … + d1×B1 + d0×B0
Pro Tip

Worked Example - Binary to Decimal — Convert 10112 to decimal: 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 1110

Conversion Techniques

Decimal → Binary (Repeated Division by 2)

Divide the number by 2 repeatedly. The remainders read bottom to top give the binary result.

Example: 13 → Binary 13 ÷ 2 = 6 remainder 1 6 ÷ 2 = 3 remainder 0 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Read up → 11012

Binary → Hexadecimal (Group by 4)

Group binary digits into sets of 4 from the right. Each group maps to one hex digit.

Example: 101101112 1011 | 0111 B | 7 Result: B716

Hex → Binary is the reverse: expand each hex digit into 4 bits.

Quick Reference: 0–15 in All Bases

DecimalBinary (4-bit)OctalHexadecimal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

Signed Binary - 2's Complement (Most Important)

Real hardware must represent negative numbers. The standard method in all modern CPUs and digital circuits is 2's complement.

Sign-Magnitude

MSB = sign bit (0=+, 1=−). Remaining bits = magnitude. Problem: has two representations of zero (+0 and −0). Rarely used in hardware.

1's Complement

Invert all bits. Still has two zeros. Addition requires an end-around carry. Mostly historical.

2's Complement

Invert all bits, then add 1. One unique zero. Subtraction becomes addition. Used in all modern computers and VLSI designs.

Pro Tip

How to Find 2's Complement of a Number — Step 1: Write the binary representation. Step 2: Invert every bit (1→0, 0→1). This is the 1's complement. Step 3: Add 1 to the result. Example: −5 in 4-bit 2's complement +5 = 0101 → Invert → 1010 → Add 1 → 1011 Range for N-bit 2's complement: −2N-1 to +2N-1−1 For 8 bits: −128 to +127

2's Complement Range
For N bits: Minimum = −2N−1 | Maximum = 2N−1 − 1

Binary Arithmetic

Binary Addition Rules

0 + 0 = 0, carry 0 0 + 1 = 1, carry 0 1 + 0 = 1, carry 0 1 + 1 = 0, carry 1 1 + 1 + 1 = 1, carry 1

Example: 0101 + 0011 0101 (5) + 0011 (3) ────── 1000 (8)

Subtraction via 2's Complement

A − B = A + (2's complement of B)

Example: 7 − 3 (4-bit) 7 = 0111 3 = 0011 → 2's comp = 1101 0111 + 1101 = 10100 Drop the carry → 0100 = 4

This is exactly how ALUs in CPUs work.

BCD - Binary Coded Decimal

BCD represents each decimal digit independently in 4 bits. Used in calculators, digital clocks, and displays where you need to show decimal digits directly.

Pro Tip

BCD Key Rules — Each decimal digit (0–9) maps to its 4-bit binary equivalent. Codes 1010–1111 (10–15) are invalid in BCD. Example: 3910 in BCD = 0011 1001 (NOT the same as 39 in pure binary which is 00100111). BCD arithmetic: if sum of two BCD digits > 9, add 0110 (6) to correct it and generate a carry.