← Back to Roadmap

0️⃣Binary & Number Systems

The language of digital electronics — binary, hex, octal, and conversions between bases.

Why Binary?

Transistors have two reliable states: ON (conducting) and OFF (non-conducting). These map perfectly to 1 and 0. Any other number system would require distinguishing multiple analog levels — much harder and less reliable. Binary is robust: even with noise, a 0.8V or 4.2V signal is clearly 0 or 1 in 5V logic. This noise immunity is why digital won over analog computing.

Binary ↔ Decimal

Each bit position represents a power of 2: ...128, 64, 32, 16, 8, 4, 2, 1. To convert binary to decimal: sum (bit × 2^position). Example: 1011_2 = 1×8 + 0×4 + 1×2 + 1×1 = 11. For decimal to binary: repeatedly divide by 2, read remainders backwards. 11/2=5R1, 5/2=2R1, 2/2=1R0, 1/2=0R1 → 1011.

Hexadecimal & Octal

Hex (base 16): 0-9, A=10, B=11, C=12, D=13, E=14, F=15. Each hex digit = 4 bits (nibble). 0xFF = 255. Used everywhere in programming: color codes (#FF0000), memory addresses (0x7FFF), MAC addresses. Octal (base 8): 0-7, each digit = 3 bits. Historically used in Unix file permissions (chmod 755). Less common now.

🎮 Interactive: Binary Counter

🎮 Interactive: Binary Counter
Increment/decrement through 0-255 — see 8-bit binary and decimal simultaneously.
0
0
0
0
0
0
0
0
0
2\u2077 2\u2076 2\u2075 2\u2074 2\u00B3 2\u00B2 2\u00B9 2\u2070

Signed Numbers & Two's Complement

Two's complement is how computers represent negative numbers. To negate: invert all bits, add 1. Example: +5 = 0101, invert = 1010, +1 = 1011 = -5. Range for n bits: -2^(n-1) to 2^(n-1)-1. 8-bit = -128 to +127. This representation makes addition/subtraction use the same hardware — a key optimization.