February 8th, 2021
Binary
- We normally use "base 10" e.g. 1's place, 10's place, 100's place, 1000's place, etc.
$$394 = 3 \times 100 + 9 \times 10 + 4 \times 1$$
$$394 = 3 \times 10^2 + 9 \times 10^1 + 4 \times 10^0$$
- Binary uses "base 2": 1's place, 2's place, 4's place, 8's place, 16's place, etc.
- Only two digits (binary digits = bits)
$$101011_2 = 1 \times 2^5 + 0 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0$$
$$= 32 + 8 + 2 + 1 = 43_{10}$$
- 8 bits = 1 byte.
$$2^{10}$$
$$2^{10}$$
$$2^{10}$$
bytes.
$$2^{20}$$
$$2^{20}$$
$$2^{20}$$
$$2^{20}$$
bytes.
$$2^{30}$$
$$2^{30}$$
$$2^{30}$$
$$2^{30}$$
bytes.
$$2^{40}$$
$$2^{40}$$
$$2^{40}$$
$$2^{40}$$
bytes.
- petabytes, exabytes, zettabytes...
Converting base 10 -> binary?
- e.g. 97
- Pick the biggest power of 2 that fits and put a 1 in that place
- Subtract that power of 2 from the number
- Repeat.