number systems
Number Bases and Binary Representation
You should know: natural numbers, integers
Overview
Positional notation represents numbers as sums of powers of a base b. Our standard system is base 10 (decimal). Binary (base 2), octal (base 8), and hexadecimal (base 16) are used in computing. In base b, the number with digits d_n d_{n-1}...d_1 d_0 represents sum_{k=0}^n d_k * b^k. Binary is fundamental to digital computing: all data is stored as bits (0 or 1). Two's complement encodes signed integers in binary.
Intuition
A number like 1101 in binary means: 1*8 + 1*4 + 0*2 + 1*1 = 13 in decimal. Each position is worth twice the previous (instead of 10x in decimal). Counting in binary: 0, 1, 10, 11, 100, 101, 110, 111, 1000... To convert decimal to binary: repeatedly divide by 2 and record remainders.
Formal Definition
Base-b representation: every non-negative integer n can be uniquely written as n = sum_{k=0}^m d_k * b^k where 0 <= d_k < b. In binary (b=2), digits are 0 or 1. Hex (b=16) uses digits 0-9, A-F. Conversion algorithm: to convert n to base b, compute n mod b (rightmost digit), then recurse on n div b. Two's complement for n-bit signed integers: represents -k as 2^n - k (flip bits and add 1).
Notation
| Notation | Meaning |
|---|---|
| Number n written in base b | |
| Binary notation (programming) | |
| Hexadecimal notation (programming) |
Theorems
Worked Examples
- 1
Divide repeatedly by 2, record remainders: 45 = 2*22+1, 22 = 2*11+0, 11 = 2*5+1, 5 = 2*2+1, 2 = 2*1+0, 1 = 2*0+1.
- 2
Read remainders from bottom to top: 101101.
- 3
Verify: 32+8+4+1 = 45. Correct.
✓ Answer
45 = 101101 in binary.
Practice Problems
Convert (1010 1100)_2 to hexadecimal.
Common Mistakes
Confusing binary digits with the value of the number.
The binary string '1000' does NOT represent 'one thousand'. It represents 1*2^3 = 8 in decimal. The string '1000' in binary is eight; in decimal it would be one thousand. Always specify the base when ambiguous.
Quiz
Historical Background
Positional notation with base 10 was developed in India (Aryabhata, 5th century AD) and transmitted to Europe via Arab mathematicians (hence 'Arabic numerals'). The Babylonians used base 60 (still seen in 60 minutes/hour, 360 degrees). Binary arithmetic was studied by Leibniz (1703) who saw it as reflecting the philosophy of creation (1 = being, 0 = nothing). George Boole (1854) developed Boolean algebra for binary logic. Shannon (1948) showed that binary logic is ideal for electronic circuits.
- 499
Aryabhata uses positional decimal notation
Aryabhata
- 1703
Leibniz publishes binary arithmetic
Gottfried Wilhelm Leibniz
- 1948
Shannon establishes information theory using binary 'bits'
Claude Shannon
Summary
- Base-b representation: n = sum d_k * b^k with digits 0 <= d_k < b.
- Binary (b=2): digits 0,1. Used in all digital computing.
- Conversion: decimal -> binary by repeated division by 2.
- Hex (b=16): 0-9,A-F. One hex digit = 4 binary bits (nibble).
References
- BookPetzold, C. Code: The Hidden Language of Computer Hardware and Software. Microsoft Press, 2000.
Mathematics