Section 4.3
4 Data Representation
4.3 Higher Number Bases
Sometimes higher number bases can be used as shorthand for binary.
4.3.1 Hexadecimal Numbers (Base 16)
In base 16 we have sixteen symbols to represent each digit.
Decimal
|
Hexadecimal
|
Binary (4-bit)
|
0
|
0
|
0000
|
1
|
1
|
0001
|
2
|
2
|
0010
|
3
|
3
|
0011
|
4
|
4
|
0100
|
5
|
5
|
0101
|
6
|
6
|
0110
|
7
|
7
|
0111
|
8
|
8
|
1000
|
9
|
9
|
1001
|
10
|
A
|
1010
|
11
|
B
|
1011
|
12
|
C
|
1100
|
13
|
D
|
1101
|
14
|
E
|
1110
|
15
|
F
|
1111
|
It is easy to convert from binary to hex and hex is easier to read than a long
string of 1s and 0s.
Converting From Binary To Hexadecimal
Step 1
Divide the binary number into groups of four digits
starting at the LSB.
|
0111
|
0101
|
Step 2
Write down the hexadecimal equivalent for each group
of digits.
|
7
|
5
|
|
011101012 = 7516
|
Converting From Hexadecimal To Denary
To perform this operation we use the same method as for converting a binary
number to decimal. However the column headings are in powers of sixteen not powers
of two.
4.3.2 Octal Numbers (Base
In the octal number system there are only eight different symbols.
Decimal
|
Hexadecimal
|
Binary (4-bit)
|
0
|
0
|
0000
|
1
|
1
|
0001
|
2
|
2
|
0010
|
3
|
3
|
0011
|
4
|
4
|
0100
|
5
|
5
|
0101
|
6
|
6
|
0110
|
7
|
7
|
0111
|
Converting Binary To Octal
Step 1
Divide the binary number into groups of three digits
starting at the LSB.
|
111
|
101
|
Step 2
Write down the hexadecimal equivalent for each group
of digits.
|
7
|
5
|
|
111 1012 = 758
|
Converting Octal To Denary
To perform this operation we use the same method as for converting a binary
number to decimal. However the column headings are in powers of eight, not two.
4.3.3 Binary Coded Decimal
This variation of binary allows denary digits to be encoded separately.
E.g. 271910 is represented by:
2
|
7
|
1
|
9
|
0010
|
0111
|
0001
|
1001
|
271910 = 0010 0111 0001 1001BCD
|
Advantages
- Easy to convert binary to BCD.
- No error due to round off.
Disadvantages
- Occupies more memory.
- Can be harder to perform arithmetic operations.
BCD Addition
Whenever the sum of any two BCD digits is greater than 10012 then
01102 has to be added to the result to skip over the unused codes.