Numbering Systems In Conputer Science
Decimal (base 10) 0 1 2
3 4 5 6 7 8 9
Natural for human beings since we are equipped with an "on-board" base 10
numbering system, i.e. 10 digits distributed evenly over two hands. Apparently our
prehistoric ancestors did not think of counting on their toes or we might have a system
based on 20.
Binary (base 2) 0 1
Natural for computers since they are made up of billions of silicon switches
which can be in one of two states, off (0) or on (1).
Hexadecimal (base 16) 0 1 2
3 4 5 6 7 8 9
A B C D E F
A very convenient compromise between the two and one that is easier for humans to
read.
Decimal-Hexidecimal-Binary Equivalent Table
Dec
|
Hex
|
Binary
|
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
|
16
|
10
|
1 0000
|
Conversion between systems
Decimal to binary using the radix divide technique.
-
Divide the given decimal integer successively by the new base (2) noting the
remainder at each step.
-
Collect the remainders (last to first) and place them left to right to form the binary
number.
Decimal to hexadecimal using the radix divide technique.
-
Divide the given decimal integer successively by the new base (16) noting the
remainder at each step.
-
Collect the remainders (last to first), convert each to a hexadecimal digit using the
table above, and place them left to right to form the hexadecimal number.
Binary to decimal using the polynomial method
Consider the decimal number 245. It can also be written as a polynomial, thus:
245 = (2 x 102) + (4 x 101) + (5 x 100).
-
Multiply each digit by its base raised to the appropriate power.
-
Add the results of each multiplication to get the decimal number
(11110101)2 = (1 x 27) + (1 x 26) + (1 x 25) + (1 x 24) + (0 x 23) + (1 x 22) +
(0 x 21) + (1 x 20)
= 128 + 64 + 32 + 16 + 0 + 4 + 0 + 1
= 245
Binary to hexadecimal using the grouping method.
-
Starting from the right, group binary digits into sets of four (add extra zeros to
the left if needed to fill out the last set of four.)
-
Convert each set of four binary digits to its' equivalent hexadecimal digit using
the table above.
Hexadecimal to decimal using the polynomial method
Consider the hexadecimal number F5. It can also be written as a polynomial, thus:
F5 = (F x 161) + (5 x 160)
-
Convert each hexadecimal digit to its' decimal equivalent and multiply it by its'
base raised to the appropriate power.
-
Add the results of each multiplication to get the decimal number.
F5 = (F x 161) + (5 x 160)
= (15 x 161) + (5 x 160)
= 240 + 5
= 245
Hexadecimal to binary using the conversion table
Convert each hexadecimal digit to its equivalent set of four binary digits using the
table above.
F5 = 1111 0101