Number Systems and Operations
TL;DR
Understanding different number systems (like binary and hexadecimal) is crucial for how computers work, as they use these systems internally to represent data. Operations within these systems, such as addition and subtraction, follow rules similar to decimal but with different base values. Mastering these concepts helps you grasp fundamental computer science principles and low-level programming.
1. The Mental Model
Think of number systems as different languages for counting. Just as you can say "one" in English or "uno" in Spanish, you can represent the quantity "ten" as '10' in decimal, 'A' in hexadecimal, or '1010' in binary. Each system just uses a different set of symbols and a different 'base' for grouping.
2. The Core Material
Computers don't understand our decimal (base-10) numbers directly. They operate using electrical signals that are either "on" or "off," which perfectly maps to binary (base-2), using only 0s and 1s. Hexadecimal (base-16) is a convenient shorthand for binary because it lets us represent large binary numbers more compactly.
### Decimal (Base-10)

Photo by Roman Friptuleac on Pexels
This is the number system you use every day. It has ten unique digits (0-9) and each digit's position represents a power of 10.
Example: $123 = (1 \times 10^2) + (2 \times 10^1) + (3 \times 10^0)$
### Binary (Base-2)

Photo by Google DeepMind on Pexels
Binary uses only two digits: 0 and 1. Each position represents a power of 2. This is the computer's native language.
Example: $101_2 = (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) = 4 + 0 + 1 = 5_{10}$
Converting Decimal to Binary
To convert a decimal numbe