Ch 2. Data Representation
Ch 2. Data Representation
2. Number System
The number system is the foundation of data representation. There are several types of
number systems used in computers:
Binary: 1011
Power of 2: 2^3, 2^2, 2^1, 2^0
1 × 2^3 = 8, 0 × 2^2 = 0, 1 × 2^1 = 2, 1 × 2^0 = 1
Sum: 8 + 0 + 2 + 1 = 11
Decimal equivalent: 11
45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 = 5 remainder 1
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1
Binary equivalent: 101101
Binary: 110101101
Group the bits: 1101 0110 1 (padded with zeros on the left for the final group).
Binary to Hexadecimal: D 6 1
Hexadecimal equivalent: D61
A = 1010, 4 = 0100
Binary equivalent: 10100100
45 ÷ 8 = 5 remainder 5
5 ÷ 8 = 0 remainder 5
Octal equivalent: 55
Steps:
Write down the binary number and assign powers of 2 to each bit starting from
the right.
Multiply each bit by the corresponding power of 2.
Binary Power of 2 Calculation Result
1 2^3 1 × 2^3 = 8 8
0 2^2 0 × 2^2 = 0 0
1 2^1 1 × 2^1 = 2 2
1 2^0 1 × 2^0 = 1 1
Steps:
Steps:
Group the binary number into sets of 4 bits (starting from the right).
If the leftmost group has fewer than 4 bits, pad it with leading zeros.
Convert each 4-bit group to its hexadecimal equivalent.
Binary: 110101101
Group the bits: 11011101 0110 1→ 0001 1010 1101 (padded with zeros on the left for
the final group). Now convert each group to hexadecimal:
1101 (binary) = D (hexadecimal)
0110 (binary) = 6 (hexadecimal)
0001 (binary) = 1 (hexadecimal)
Hexadecimal equivalent of binary 110101101 = D61.
Steps:
Steps:
Steps: