http://www

advertisement
Decimal / Hexadecimal Conversion
Hexadecimal Number System [Base-16]
The hexadecimal number system uses sixteen values to represent numbers. The values
are,
0123456789ABCDEF
with 0 having the least value and F having the greatest value. Columns are used in the
same way as in the decimal system, in that the left most column is used to represent the
greatest value.
As we have seen in the decimal system, the values in the set (0 and 1) repeat, in both the
vertical and horizontal directions.
0 - F, 10 -1F, 20 - 2F, 30 - 3F ......
Hexadecimal is often used to represent values [numbers and memory addresses] in
computer systems.
Decimal - Binary - Hexadecimal
Decimal Binary Hexadecimal
CIS 125 Discrete Math
0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
7
8
1000
8
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
1
Converting decimal to hexadecimal
Problem: Convert 232 decimal to hexadecimal.
Use the method used earlier to convert decimal to binary, but divide by 16 instead of by
2.
232 / 16 = 14 with a remainder of 8
14 / 16 = 0 with a remainder of E (14 decimal = E)
= E816
Another method is to convert the decimal value into a binary number, and then convert
that result as shown below.
Converting hexadecimal to decimal
Problem: Convert 176 in hexadecimal to decimal.
Each column represents a power of 16,
176 =
---- 6 * 160 =
6
----- 7 * 161 = 112
------ 1 * 162 = 256
---374
Converting binary to hexadecimal
Problem: Convert 10110 to hexadecimal.
Each hexadecimal digit represents 4 binary bits. Split the binary number into groups of 4
bits, starting from the right. In this case, 10110 is equivalent to 00010110, so we can split
the binary number like this:
0001 0110
The left group, 0001, is equal to 1.
The right group, 0110, is equal to 6.
Because both digits are less than ten, we can simply combine them for the answer.
= 16 in hexadecimal, or 1616
CIS 125 Discrete Math
2
To avoid confusion, we often add a suffix to indicate the number base
162h
h means hexadecimal
16216
16 means base 16
162d
d means decimal
16210
10 means base 10
162o
o means octal
1628
8 means base 8
101b
b means binary
1012
2 means base 2
Sample Problems for Hexadecimal Conversion
In each case, don’t simply convert the value, but consider which value cannot be the
solution, thus narrowing the choices and making your job easier.
1. 1010101b in hexadecimal is
__ 6616
__ 5516
__ 4416
__ 64516
2. 1000100b in hexadecimal is
__ 4416
__ 3316
__ 4316
__ 3416
3. 0010010b in hexadecimal is
__ 1116
__ 2216
__ 2116
__ 1216
4. 0111101b in hexadecimal is
__ 3D16
__ DE16
__ F316
__ 0916
5. BCD16 in decimal is
__ 213210
__ 321010
__ 302110
__ 102310
CIS 125 Discrete Math
3
6. AF16 in decimal is
__ 71510
__ 7110
__ 5710
__ 17510
7. 9216 in decimal is
__ 6410
__ 14610
__ 1610
__ 4110
8. 7E16 in decimal is
__ 12610
__ 12710
__ 7110
__ 114d
CIS 125 Discrete Math
4
Download