There are different systems that can be use to write a certain number.
As an example, if we need to write the number ‘sixty-three’, we can use different numbering systems, as will be illustrated in this section.
We learned this ordinary system from the childhood.
This system is formed from 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) so; it is called the ‘decimal numbering system’.
As an example, to write ‘sixty-three’ in the decimal numbering system, we simply write ‘63’.
This is a numbering system that is formed from 16 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F).
As an example, if we need to write ‘sixty-three’ in the hexadecimal numbering system, we will write ‘3F’.
The digits from ‘A’ to ‘F’ in the hexadecimal system are equivalent to the numbers from ‘10’ to ‘15’ in the decimal system respectively.
Figure 2.1: the relation between the hexadecimal and the decimal numbering systems.
This numbering system is formed from only two digits (0 and 1).
As an example, if we need to write ‘sixty-three’ in the binary numbering system, we will write ‘00111111’.
Binary numbering system, basic information
If we wrote a binary number ‘10010010’, we should know the following,
Figure 2.2: the binary number basic elements
This means that, 8 bits = 2 nibbles = 1 byte.
To convert a number from the binary numbering system to the decimal numbering system, we should know the weight of every binary digit (bit) in this binary number.
The weight of every bit depends on its location in the binary number.
The MSB has the highest weight, while the LSB has the least weight.
As an example, if we have a binary number that is formed from eight bits. The weight of every bit will be as following,
Figure 2.3: the binary digits weight
The LSB weight = 1
The MSB weight = 128
To convert from the binary numbering system to the decimal numbering system, we multiply every bit by its weight then we aggregate all the results.
Example:
Convert the following binary number ‘10010010’ to the decimal numbering system.
Answer:
We multiply every bit by its weight, and then we aggregate all the results.
So, the binary number ‘10010010’ = the decimal number ‘146’.
To convert from the decimal system to the binary system, we will also use the binary digits weight.
Figure 2.4: the binary digits weight
The way of conversion is as following,
We take the decimal number and divide it over the first weight 128.
We write the result as the MSB in the binary number, and take the remaining and divide it over the second weight 64.
We write the result as the bit before MSB, and take the remaining and divide it over the third weight 32.
….
We continue doing the previous steps until the last weight 1.
Convert the decimal number ‘65’ to its equivalent binary number.
65/128 = 0 and remaining 65
65/64 = 1 and remaining 1
1/32 = 0 and remaining 1
1/16 = 0 and remaining 1
1/8 = 0 and remaining 1
1/4 = 0 and remaining 1
1/2 = 0 and remaining 1
1/1 = 1 and remaining 0
So, the equivalent binary number will be = 01000001
Convert the decimal number ‘133’ to its equivalent binary number.
133/128 = 1 and remaining 5
5/64 = 0 and remaining 5
5/32 = 0 and remaining 5
5/16 = 0 and remaining 5
5/8 = 0 and remaining 5
5/4 = 1 and remaining 1
1/2 = 0 and remaining 1
1/1 = 1 and remaining 0
So, the equivalent binary number will be = 10000101
The digits from ‘A’ to ‘F’ in the hexadecimal system are equivalent to numbers from ‘10’ to ‘15’ in the decimal system respectively.
Figure 2.5: the relation between the hexadecimal and the decimal numbering systems.
To convert from the hexadecimal system to the binary system, we do the following,
Figure (2.6) illustrates how we can convert from the hexadecimal numbering system to the binary numbering system.
Figure 2.7: hexadecimal to binary conversion
To convert from the binary system to the hexadecimal system, we make the following.
Figure 2.7: hexadecimal to binary conversion
The digits from ‘A’ to ‘F’ in the hexadecimal system are equivalent to numbers from ‘10’ to ‘15’ in the decimal system respectively.
Figure 2.7: binary to hexadecimal conversion
To convert from the hexadecimal system to the decimal system, we do the following,
Figure (2.9) illustrates how we can convert from the hexadecimal numbering system to the decimal numbering system.
Figure 2.9: convert from the hexadecimal to the decimal numbering systems.
To convert from the decimal system to the hexadecimal system, we make the opposite steps of the previous operation.
Figure 2.10: decimal to hexadecimal conversion