Understanding the Basics of Number System Conversion

Introduction

Number systems are essential in computing and digital systems for the representation and manipulation of data. Knowing how to switch between varying number systems is crucial in the field of computer science and coding. This blog will explore the fundamental principles of converting number systems, such as binary, decimal, octal, and hexadecimal systems.

Conversion between Number Bases

Computers and other digital systems process information as their primary function. Therefore, it is necessary to have methods and systems for representing information in forms, which can be manipulated and stored using electronic or other types of software.

As discussed earlier, internally computer uses binary numbers for data representation whereas externally it uses decimal numbers. However, any number in one number system can be represented in another number system. Various methods, which can be used to convert numbers from one base to another are discussed in the following sections.

Converting Decimal to Binary, Octal, and Hexadecimal

The method used for the conversion of decimal number into other number systems is often done using the ‘remainder’ method. This method involves the following steps:
  1. Divide the decimal number by the base of the target number system. That is, to convert decimal to binary, divide the decimal number with 2 (the base of binary number system), 8 for octal, and 16 for hexadecimal.
  2. Note the remainder separately as the first digit from the right. In case of hexadecimal, if the remainder exceeds 9, convert the remainder into equivalent hexadecimal form. For example, if the remainder is 10 then note the remainder as A.
  3. Continually repeat the process of dividing until the quotient is zero and keep writing the remainders after each step of division.
  4. Finally, when no more division can occur, write down the remainders in reverse order.

Example 1

Determine the binary equivalent of `left(36right)_10`
Ans: 18 × 2=36,     Remainder=0
         9 × 2=18,        Remainder=0
         4 × 2=8,          Remainder=1
         2 × 2=4,          Remainder=0
         1 × 2=2,          Remainder=0
         0 × 2=0,         Remainder=1
Taking remainders in reverse order, we have 100100. Thus, the binary equivalent of `left(36right)_10` is `left(100100right)_2`.

Example 2

Determine the octal equivalent of  `left(359right)_10`
Ans: 44 × 8=359,       Remainder=7
         5 × 8=40,             Remainder=4
         0 × 8=0,               Remainder=5
Thus, the octal equivalent of `left(359right)_10` is `left(547right)_8`.

Example 3

Determine the hexadecimal equivalent of `left(5112right)_10`
Ans: 319 × 16=5112,         Remainder= (8=8)
         19 × 16=319,               Remainder= (15=F)
         1 × 16=19,                   Remainder= (3=3)
         0 × 16=1,                    Remainder= (1=1)
Thus, the hexadecimal equivalent of `left(5112right)_10` is `left(13F8right)_16`.

Converting Binary, Octal, and Hexadecimal to Decimal

The method used for conversion of a binary, octal, or hexadecimal number to decimal number involves each digit of the binary, octal, or hexadecimal number to be multiplied by its weighted position, and then each of the weighted values is added together to get the decimal number.

Example 1

Determine the decimal equivalent of `left(11010right)_2`
Binary Number 1 1 0 1 0
Weight of Each Bit `2^4` `2^3` `2^2` `2^1` `2^0`
Weighted Value `2^4times1` `2^3times1` `2^2times0` `2^1times1` `2^0times0`
Solved Multiplication 16 8 0 2 0
Sum of weight of all bits = 16 + 8 + 0 + 2 + 0 = 26
Thus, the decimal equivalent of `left(11010right)_2` is `left(26right)_10`

Example 2

Determine the decimal equivalent of `left(456right)_8`
Octal Number 4 5 6
Weight of Each Bit `8^2` `8^1` `8^0`
Weighted Value `8^2times4` `8^1times5` `8^0times6`
Solved Multiplication 256 40 6
Sum of weight of all bits = 256 + 40 +6 = 302
Thus, the decimal equivalent of `left(456right)_8` is `left(302right)_10`

Example 3

Determine the decimal equivalent of `left(B14right)_16`
Hexadecimal Number B = 11 1 4
Weight of Each Bit `16^2` `16^1` `16^0`
Weighted Value `16^2times11` `16^1times1` `16^0times4`
Solved Multiplication 2816 16 4
Sum of weight of all bits = 2816 + 16 + 4 = 2836
Thus, the decimal equivalent of `left(B14right)_16` is `left(2836right)_10`.

Converting among Binary, Octal, and Hexadecimal

Converting among binary, octal, and hexadecimal can be accomplished easily without converting to decimal first, as the base numbers of all three systems (2, 8, and 16) are powers of 2. Any octal digit can be written as a group of three binary digits while a hexadecimal number will comprise four binary digits.

Example 1

Determine the octal equivalent of `left(010111right)_2`
Binary number 010 111
Octal number 2 7

The octal equivalent of `left(010111right)_2` is `left(27right)_8`

Example 2

Determine the hexadecimal equivalent of  `left(11001011right)_2`
Binary number 1100 1011
Decimal number 12 11
Hexadecimal Number C B
The hexadecimal equivalent of  `left(11001011right)_2` is `left(CBright)_16`

Example 3

Determine the binary equivalent of `left(231right)_8`
Octal number 2 3 1
Binary Value 010 011 001
Thus, the binary equivalent of `left(231right)_8` is `left(010011001right)_2`

Example 4

Determine the binary equivalent of `left(5AFright)_16`
Hexadecimal Number 5 A F
Binary Value 0101 1010 1111

Thus, the binary equivalent of  `left(5AFright)_16` is `left(010110101111right)_2`

Converting between Octal and Hexadecimal

The method used for the conversion of octal number to hexadecimal number is accomplished by the following steps:
  1. Convert each octal digit to 3-bit binary form.
  2. Combine all the 3-bit binary numbers.
  3. Segregate the binary numbers into the 4-bit binary form by starting the first number from the right bit (LSB) towards the number on the left bit (MSB).
  4. Finally, convert these 4-bit blocks into their respective hexadecimal symbols.

Example 1

Determine the hexadecimal equivalent of `left(2327right)_8`
Octal number 2 3 2 7
Binary value 010 011 010 111
Combining the 3-bit binary blocks, we have 010011010111. Separating the group of binary numbers (from left side) into the 4-bit binary number and by converting these blocks into their respective hexadecimal symbols, we have;
0100 1101 0111
4 D 7

Thus, the hexadecimal equivalent of `left(2327right)_8` is `left(4D7right)_16`

The method used for the conversion of hexadecimal number to octal number is the same as the octal to hexadecimal conversion except that each hexadecimal digit is converted into 4-bit binary form and then after grouping of all the 4-bit binary blocks, it is converted into the 3-bit binary form. Finally,these 3-bit binary forms are converted into octal symbols.

Example 2

Determine the octal equivalent of `left(2B6right)_16`
Hexadecimal Number 2 B 6
Binary value 0010 1011 0110
Combining all the 4-bit binary blocks, we have 001010110110.Separating the group of binary numbers into the 3-bit binary blocks and by converting these blocks into octal symbols, we have:
001 010 110 110
1 2 6 6
Thus, the octal equivalent of `left(2B6right)_16` is `left(1266right)_8`

Conclusion

Having a grasp of number system conversion is crucial for individuals in the fields of computer programming, engineering, and mathematics. Proficiency in these ideas allows for effective handling and portrayal of data, which plays a role in creating cutting-edge technologies that impact our digital environment.

Leave a Reply

Your email address will not be published. Required fields are marked *