L1: Number Systems
What life would be like with a different number of fingers.
Objective
Gain a solid understanding of positional number systems, their significance in digital circuits, and how to convert between binary, octal, decimal, and hexadecimal representations.
Additional Materials & Formats
Check Box for the most up-to-date versions of this lecture’s materials.
Before the Lecture
Required Textbook Reading:
- 1.5 (Digital Representation of Information)
- 3.1 (Positional Number Representation)
- 3.7 (Other Number Representations)
Optional Supplemental Instruction:
- Khan Acadamy Videos: Alternate Number Bases
(there are 8 useful videos available in the sidebar)
The Punchline
Positional number systems represent a number using a radix (or base), and each position represents a power of that base. Any number in a positional system can be expressed as a sum of powers of the base.
Positional Representation in Base 10
In base 10 (the decimal system), numbers are represented using the digits 0 through 9. Each position in a number corresponds to a power of 10, starting from the rightmost digit (the least significant digit).
For example, the number 345 in base 10 can be expressed as:
$$ 345 = 3 \times 10^2 + 4 \times 10^1 + 5 \times 10^0 $$
The table below offers a structured breakdown of how the number 345 is represented in base 10. By summing the values from the last row, we get the total: $300 + 40 + 5 = 345$.
| Place | 100s | 10s | 1s |
|---|---|---|---|
| Power | $10^2$ | $10^1$ | $10^0$ |
| Digit | 3 | 4 | 5 |
| Value | $3 \times 10^2 = 300$ | $4 \times 10^1 = 40$ | $5 \times 10^0 = 5$ |
This breakdown demonstrates the concept of positional number systems, where the value of a digit depends on both the digit itself and its position within the number.
Counting on Fingers
Base 10 is intuitive because it is how we naturally count and perform arithmetic in everyday life.
Imagine counting on your fingers. You start with your first finger for 1, then your second finger for 2, and so on. Once you reach 10, you run out of fingers. To keep counting, you might make a mark on a piece of paper to represent one “set of 10” and start over with your fingers.
This is how positional number systems work. Each time you reach the base (in this case, 10), you “carry over” to the next position. For example:
- 0: No fingers up.
- 1: First finger up.
- 2: Second finger up.
- …
- 10: Make a mark (representing one set of 10) and start over with no fingers up.
This concept can be extended to other bases. For instance, in base 2 (binary), you would only use two states (finger up or down), and once you reach 2, you carry over to the next position. Similarly, in base 16 (hexadecimal), you would count up to 16 before carrying over.
Radix (Base) and Its Annotation
The radix (or base) of a number system determines the number of unique digits, including zero, that the system uses to represent numbers. For example:
- In base 10 (decimal), the digits are 0 through 9.
- In base 2 (binary), the digits are 0 and 1.
- In base 16 (hexadecimal), the digits are 0 through 9 and A through F.
The radix also defines the value of each positional place in a number. Each position represents a power of the base, starting from $b^0$ at the rightmost digit.
Annotating Numbers with a Radix
To avoid ambiguity, numbers in different bases are often annotated with a subscript or prefix indicating their radix:
- Subscript Notation: The base is written as a subscript after the number.
- Example: $1011_2$ (binary), $345_{10}$ (decimal), $\text{EC}_{16}$ (hexadecimal).
- Prefix Notation: A prefix is added to the number to indicate the base.
- Binary:
0b1011 - Octal:
0o345 - Hexadecimal:
0x1A
- Binary:
- Function Notation: The base is written using a function-like notation. For example:
dec(30)represents the number 30 in decimal (base 10).oct(28)represents the number 28 in octal (base 8).bin(1011)represents the number 1011 in binary (base 2).hex(1A)represents the number 1A in hexadecimal (base 16).
This notation is often used in programming and documentation to explicitly indicate the base of a number, especially when working with multiple number systems.
These annotations help clarify the intended base, especially when working with multiple number systems in the same context.
Positional Representation in Other Radixes
Positional number systems represent numbers using a specific base (or radix), where each position corresponds to a power of the base. The value of a number is determined by summing the products of each digit and its corresponding positional value.
Common Number Systems
In digital systems, bases that are powers of two (e.g., binary, octal, hexadecimal) are preferred because they align with the binary architecture of computers. Computers use bits (0 or 1) as their fundamental unit, and grouping bits into powers of two simplifies representation and computation.
Binary (Base 2)
- Digits: 0, 1
- Positional Value: Each position represents a power of 2.
- Example: $1011_2 = (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 11_{10}$
Octal (Base 8)
- Digits: 0, 1, 2, 3, 4, 5, 6, 7
- Positional Value: Each position represents a power of 8.
- Example: $345_8 = (3 \times 8^2) + (4 \times 8^1) + (5 \times 8^0) = 229_{10}$
Hexadecimal (Base 16)
- Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (where A=10, B=11, …, F=15)
- Positional Value: Each position represents a power of 16.
- Example: $1A_{16} = (1 \times 16^1) + (10 \times 16^0) = 26_{10}$
Why Powers of Two?
In digital systems, bases that are powers of two (e.g., binary, octal, hexadecimal) are preferred because they align with the binary architecture of computers. Computers use bits (0 or 1) as their fundamental unit, and grouping bits into powers of two simplifies representation and computation.
For example:
- Binary (Base 2): Represents individual bits.
- Octal (Base 8): Groups 3 bits per digit ($2^3 = 8$).
- Hexadecimal (Base 16): Groups 4 bits per digit ($2^4 = 16$).
These bases are practical because they map directly to binary, making it easier to interpret and manipulate data. While other bases are possible, they are less efficient and not widely adopted due to their misalignment with binary systems and established standards.
Conversions Between Number Systems
Binary to Decimal
To convert a binary number to decimal, multiply each binary digit by its positional value (a power of 2) and sum the results.
$$ 1011_2 = (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) $$
$$ 1011_2 = 8 + 0 + 2 + 1 = 11_{10} $$
Decimal to Binary
To convert a decimal number to binary, repeatedly divide the number by 2, recording the remainders. The binary representation is the remainders read in reverse order.
- $13 \div 2 = 6$ remainder $1$
- $6 \div 2 = 3$ remainder $0$
- $3 \div 2 = 1$ remainder $1$
- $1 \div 2 = 0$ remainder $1$
Reading the remainders from bottom to top, $13_{10} = 1101_2$.
Decimal to Hexadecimal
To convert a decimal number to hexadecimal, repeatedly divide the number by 16, recording the remainders. Convert remainders greater than 9 to their hexadecimal equivalents (A-F). The hexadecimal representation is the remainders read in reverse order.
- $255 \div 16 = 15$ remainder $15$ ($15 = F$ in hexadecimal)
- $15 \div 16 = 0$ remainder $15$ ($15 = F$ in hexadecimal)
Reading the remainders from bottom to top, $255_{10} = FF_{16}$.
Hexadecimal to Decimal
To convert a hexadecimal number to decimal, multiply each hexadecimal digit by its positional value (a power of 16) and sum the results.
$$ 1A_{16} = (1 \times 16^1) + (10 \times 16^0) $$
$$ 1A_{16} = 16 + 10 = 26_{10} $$
Binary to Octal
To convert a binary number to octal, group the binary digits into sets of three (starting from the right) and convert each group to its octal equivalent.
- Group the binary digits: $101101_2 = 101\ 101$
- Convert each group:
- $101_2 = 5_8$
- $101_2 = 5_8$
Thus, $101101_2 = 55_8$.
Octal to Binary
To convert an octal number to binary, convert each octal digit to its 3-bit binary equivalent.
- Convert each digit:
- $3_8 = 011_2$
- $4_8 = 100_2$
- $5_8 = 101_2$
Thus, $345_8 = 011100101_2$.
Binary to Hexadecimal
To convert a binary number to hexadecimal, group the binary digits into sets of four (starting from the right) and convert each group to its hexadecimal equivalent.
- Group the binary digits: $11011101_2 = 1101\ 1101$
- Convert each group:
- $1101_2 = D_{16}$
- $1101_2 = D_{16}$
Thus, $11011101_2 = DD_{16}$.
Hexadecimal to Binary
To convert a hexadecimal number to binary, convert each hexadecimal digit to its 4-bit binary equivalent.
- Convert each digit:
- $1_{16} = 0001_2$
- $F_{16} = 1111_2$
Thus, $1F_{16} = 00011111_2$.
Discussion
Why do engineers get confused about Christmas and Halloween?
Practice Exercises
-
Convert $1101_2$ to decimal.
View Solution
$$ 1101_2 = (1 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) $$ $$ 1101_2 = 8 + 4 + 0 + 1 = 13_{10} $$
-
Convert $101010_2$ to decimal
View Solution
$$ 101010_2 = (1 \times 2^5) + (0 \times 2^4) + (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (0 \times 2^0) $$ $$ 101010_2 = 32 + 0 + 8 + 0 + 2 + 0 = 42_{10} $$
-
Convert $11101_2$ to decimal
View Solution
$$ 11101_2 = (1 \times 2^4) + (1 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) $$ $$ 11101_2 = 16 + 8 + 4 + 0 + 1 = 29_{10} $$
-
Convert $100110_2$ to decimal
View Solution
$$ 100110_2 = (1 \times 2^5) + (0 \times 2^4) + (0 \times 2^3) + (1 \times 2^2) + (1 \times 2^1) + (0 \times 2^0) $$ $$ 100110_2 = 32 + 0 + 0 + 4 + 2 + 0 = 38_{10} $$
-
Convert $45_{10}$ to binary
View Solution
$$ 45 \div 2 = 22 , \text{remainder} , 1 $$ $$ 22 \div 2 = 11 , \text{remainder} , 0 $$ $$ 11 \div 2 = 5 , \text{remainder} , 1 $$ $$ 5 \div 2 = 2 , \text{remainder} , 1 $$ $$ 2 \div 2 = 1 , \text{remainder} , 0 $$ $$ 1 \div 2 = 0 , \text{remainder} , 1 $$ Reading the remainders from bottom to top: $$ 45_{10} = 101101_2 $$
-
Convert $73_{10}$ to binary
View Solution
$$ 73 \div 2 = 36 , \text{remainder} , 1 $$ $$ 36 \div 2 = 18 , \text{remainder} , 0 $$ $$ 18 \div 2 = 9 , \text{remainder} , 0 $$ $$ 9 \div 2 = 4 , \text{remainder} , 1 $$ $$ 4 \div 2 = 2 , \text{remainder} , 0 $$ $$ 2 \div 2 = 1 , \text{remainder} , 0 $$ $$ 1 \div 2 = 0 , \text{remainder} , 1 $$ Reading the remainders from bottom to top: $$ 73_{10} = 1001001_2 $$
-
Convert $110011_2$ to decimal
View Solution
$$ 110011_2 = (1 \times 2^5) + (1 \times 2^4) + (0 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) $$ $$ 110011_2 = 32 + 16 + 0 + 0 + 2 + 1 = 51_{10} $$
-
Convert $57_{10}$ to binary
View Solution
$$ 57 \div 2 = 28 , \text{remainder} , 1 $$ $$ 28 \div 2 = 14 , \text{remainder} , 0 $$ $$ 14 \div 2 = 7 , \text{remainder} , 0 $$ $$ 7 \div 2 = 3 , \text{remainder} , 1 $$ $$ 3 \div 2 = 1 , \text{remainder} , 1 $$ $$ 1 \div 2 = 0 , \text{remainder} , 1 $$ Reading the remainders from bottom to top: $$ 57_{10} = 111001_2 $$
-
Convert $3F_{16}$ to decimal
View Solution
$$ 3F_{16} = (3 \times 16^1) + (15 \times 16^0) $$ $$ 3F_{16} = 48 + 15 = 63_{10} $$
-
Convert $101101_2$ to hexadecimal
View Solution
Group the binary digits into sets of four (starting from the right):
$$ 101101_2 = 0010\ 1101 $$ Convert each group: $$ 0010_2 = 2_{16}, , 1101_2 = D_{16} $$ $$ 101101_2 = 2D_{16} $$ -
Convert $72_{10}$ to octal
View Solution
$$ 72 \div 8 = 9 , \text{remainder} , 0 $$ $$ 9 \div 8 = 1 , \text{remainder} , 1 $$ $$ 1 \div 8 = 0 , \text{remainder} , 1 $$ Reading the remainders from bottom to top: $$ 72_{10} = 110_8 $$
-
Convert $110_8$ to binary
View Solution
Convert each octal digit to its 3-bit binary equivalent: $$ 1_8 = 001_2, , 1_8 = 001_2, , 0_8 = 000_2 $$ Combine the binary groups: $$ 110_8 = 001001000_2 $$
-
Convert $7B_{16}$ to binary
View Solution
Convert each hexadecimal digit to its 4-bit binary equivalent: $$ 7_{16} = 0111_2, , B_{16} = 1011_2 $$ Combine the binary groups: $$ 7B_{16} = 01111011_2 $$
-
Convert $10101010_2$ to octal
View Solution
Group the binary digits into sets of three (starting from the right):
$$ 10101010_2 = 010\ 101\ 010 $$ Convert each group: $$ 010_2 = 2_8, , 101_2 = 5_8, , 010_2 = 2_8 $$ $$ 10101010_2 = 252_8 $$