Digital systems manipulate discrete quantities of information that are represented in binary form.
A binary number is a number system with a base of 2. The digits of the binary number system have only two possible values: \(0\) and \(1\). Each binary digit is called a bit \((\textrm{b})\). A group of four bits \((4\,\textrm{b})\) is called a nibble, and a group of eight bits \((8\,\textrm{b})\) is called a byte \((\textrm{B})\).
In general, using \(n\) bits allows representation of positive integers in the range from \(0\) to \(2^n - 1\) (or \(2^n\) possible values).
In a binary number the rightmost bit is usually referred to as the least-significant bit (LSB). The leftmost bit, which has the highest power of \(2\) associated with it, is called the most-significant bit (MSB).
For the capacities of computer storage systems, the SI prefixes are commonly used with their decimal values (powers of \(10\)). The International Electrotechnical Commission (IEC) issued a standard by defining a series of binary prefixes that use \(1024\) instead of \(1000\) as the main radix.
Symbol | IEC Binary Prefix | Value |
---|---|---|
\(\displaystyle\textrm{Ki}\) | kibi, binary kilo | \(\displaystyle 2^{10} = 1024\) |
\(\displaystyle\textrm{Mi}\) | mebi, binary mega | \(\displaystyle 2^{20} = 1024^2\) |
\(\displaystyle\textrm{Gi}\) | gibi, binary giga | \(\displaystyle 2^{30} = 1024^3\) |
\(\displaystyle\textrm{Ti}\) | tebi, binary tera | \(\displaystyle 2^{40} = 1024^4\) |
\(\displaystyle\textrm{Pi}\) | pebi, binary peta | \(\displaystyle 2^{50} = 1024^5\) |
\(\displaystyle\textrm{Ei}\) | exbi, binary exa | \(\displaystyle 2^{60} = 1024^6\) |
\(\displaystyle\textrm{Zi}\) | zebi, binary zetta | \(\displaystyle 2^{70} = 1024^7\) |
\(\displaystyle\textrm{Yi}\) | yobi, binary yotta | \(\displaystyle 2^{80} = 1024^8\) |
The JEDEC memory standard notes that the definitions of kilo \((\textrm{K})\), giga \((\textrm{G})\), and mega \((\textrm{M})\) based on powers of \(2\) are included only to reflect common usage, but are otherwise deprecated.
See: Units of Information
Octal and Hexadecimal Numbers
Since \(2^3 = 8\) and \(2^4 = 16\), each octal (base-8) digit corresponds to three binary digits and each hexadecimal (base-16) digit corresponds to four binary digits.
Decimal (base-10) | Binary (base-2) | Octal (base-8) | Hexadecimal (base-16) |
---|---|---|---|
\(\displaystyle 00\) | \(\displaystyle 0000\) | \(\displaystyle 00\) | \(\displaystyle 0\) |
\(\displaystyle 01\) | \(\displaystyle 0001\) | \(\displaystyle 01\) | \(\displaystyle 1\) |
\(\displaystyle 02\) | \(\displaystyle 0010\) | \(\displaystyle 02\) | \(\displaystyle 2\) |
\(\displaystyle 03\) | \(\displaystyle 0011\) | \(\displaystyle 03\) | \(\displaystyle 3\) |
\(\displaystyle 04\) | \(\displaystyle 0100\) | \(\displaystyle 04\) | \(\displaystyle 4\) |
\(\displaystyle 05\) | \(\displaystyle 0101\) | \(\displaystyle 05\) | \(\displaystyle 5\) |
\(\displaystyle 06\) | \(\displaystyle 0110\) | \(\displaystyle 06\) | \(\displaystyle 6\) |
\(\displaystyle 07\) | \(\displaystyle 0111\) | \(\displaystyle 07\) | \(\displaystyle 7\) |
\(\displaystyle 08\) | \(\displaystyle 1000\) | \(\displaystyle 10\) | \(\displaystyle 8\) |
\(\displaystyle 09\) | \(\displaystyle 1001\) | \(\displaystyle 11\) | \(\displaystyle 9\) |
\(\displaystyle 10\) | \(\displaystyle 1010\) | \(\displaystyle 12\) | \(\displaystyle \mathrm{A}\) |
\(\displaystyle 11\) | \(\displaystyle 1011\) | \(\displaystyle 13\) | \(\displaystyle \mathrm{B}\) |
\(\displaystyle 12\) | \(\displaystyle 1100\) | \(\displaystyle 14\) | \(\displaystyle \mathrm{C}\) |
\(\displaystyle 13\) | \(\displaystyle 1101\) | \(\displaystyle 15\) | \(\displaystyle \mathrm{D}\) |
\(\displaystyle 14\) | \(\displaystyle 1110\) | \(\displaystyle 16\) | \(\displaystyle \mathrm{E}\) |
\(\displaystyle 15\) | \(\displaystyle 1111\) | \(\displaystyle 17\) | \(\displaystyle \mathrm{F}\) |
The conversion from binary to octal (base-8) is easily accomplished by partitioning the binary number into groups of three digits each, starting from the binary point and proceeding to the left and to the right. Conversion from binary to hexadecimal (base-16) is similar, except that the binary number is divided into groups of four digits.
For example, convert binary number \(N = (10110001101011.111100000110)_2\) to octal and hexadecimal number
To octal number,
\(\displaystyle N = (10\;110\;001\;101\;011\;.\;111\;100\;000\;110)_2 = (2\;6\;1\;5\;3\;.\;7\;4\;0\;6)_8\)
To hexadecimal number,
\(\displaystyle N = (10\;1100\;0110\;1011\;.\;1111\;0000\;0110)_2 = (2\;\mathrm{C}\;6\;\mathrm{B}\;.\;\mathrm{F}\;0\;6)_{16}\)
\(\displaystyle N = (10110001101011.111100000110)_2 = (26153.7406)_8 = (\mathrm{2C6B}.\mathrm{F06})_{16}\)
Conversion from octal or hexadecimal to binary is done by reversing the preceding procedure. Each octal digit is converted to its three-digit binary equivalent. Similarly, each hexadecimal digit is converted to its four-digit binary equivalent.