$\require{cancel}$
Base 2 or Binary
- Why do you suppose you know base 10?
- We use base 2, or binary in computing.
- Probably because it is easy to tell if there is a positive charge or not.
- Or if a switch is on or off.
- As we will see, this is not the only way we could do it.
- But it is the way we do it.
- Comparison with base 10
- In base 10 there are 10 digits, {0,1,2,3,4,5,6,7,8,9}
- In base 2 there are 2 digits {0,1}
- In base 10, the radix is 10
- In base 2, the radix is 2
- In base 10 a number is : $d_n10^n + d_{n-1}10^{n-1} + ... + d_110+d_0$, where $d_i \in \{0,1,2,3,4,5,6,7,8,9\}$
- In base 2 a number is : $d_n2^n + d_{n-1}2^{n-1} + ... + d_12+d_0$, where $d_i \in \{0,1\}$
- We subscript binary numbers with a 2, to indicate binary.
- $10110_2$ is a binary number
- 10110 is a decimal number
- In general we do not subscript base 10 numbers.
- But if we want $10110_{10}$ is what we would write.
- Some Terms
- A single binary digit is called a bit.
- A collection of 8 bits is called a byte.
- The first bit is the most significant bit (MSB).
- The last bit is the least significant bit (LSB).
- The term word is hardware dependent.
- It means the "size of data" in a computer.
- Some other terms, less frequently used
- Multiple words, bits and bytes
- Word:
- A half word is half of a word
- A double word is two words
- A quad word is four words.
- We know these terms from programming (double, quad, ...)
- Bits and bytes use the metric prefixes
-
value | Metric |
$10^3$ | kilo (k) |
$10^6$ | mega (M) |
$10^9$ | giga (G) |
$10^{12}$ | tera (T) |
$10^{15}$ | peta (P) |
$10^{18}$ | exa (E) |
$10^{21}$ | zetta (Z) |
$10^{24}$ | yotta (Y) |
$10^{27}$ | ronna (R) |
$10^{30}$ | quetta (Q) |
- In metric we use the term bit/byte so
- 1kb (b is for bit) is 1,000 bits.
- 1kB (B is for byte) is 1,000 bytes or 8,000 bits.
- 1 Yb is 1,000,000,000,000,000,000,000,000 bits, and that is a lotta bits!
- A second system by the IEC defines prefixes in powers of 2.
value | Metric |
$2^{10} = 1024^1$ | kibi (k) |
$2^{20} = 1024^2$ | mibi (M) |
$2^{30} = 1024^3$ | gibi (G) |
$2^{40} = 1024^4$ | tebi (T) |
$2^{50} = 1024^5$ | pebi (P) |
$2^{60} = 1024^6$ | exbi (E) |
$2^{70} = 1024^7$ | zebi (Z) |
$2^{80} = 1024^8$ | yobi (Y) |
- So in this system
- 5 kibibytes (KiB) = 5 x 2^10 bytes.
- I am fairly certain that this system was introduced due to a lawsuit where advertisers misused the term megabyte
- And I really don't care
- But I think you should know up to yotta.
- Because look here.
- What types of devices are measured in bits, bytes, and the other units?