”;
What is Hexadecimal Arithmetic?
In digital electronics, hexadecimal numbers are used to represent binary information in more compact form, as one hexadecimal digit can represent a group of 4 binary digits. Therefore, hexadecimal numbers and arithmetic operation on them play a vital role in the field of digital electronics.
Hexadecimal arithmetic is a mathematical system that allows to perform arithmetic operations such as addition, subtraction, multiplication, and division of hexadecimal or base-16 numbers.
In this chapter, we will cover the following four basic hexadecimal arithmetic operations −
- Hexadecimal Addition
- Hexadecimal Subtraction
- Hexadecimal Multiplication
- Hexadecimal Division
Let’s understand each of the hexadecimal arithmetic operations in detail with the help of examples.
Hexadecimal Addition
Hexadecimal addition is one of the basic arithmetic operations performed on hexadecimal numbers to determine their sum. Basically, hexadecimal addition is similar to decimal addition. But in hexadecimal addition, a carry is generated to the next higher column if the sum is greater than or equal to 16.
Let us see some solved examples to better understand the hexadecimal addition.
Example 1
Add (5A)16 and (BF)16.
Solution
The addition of the given hexadecimal numbers is shown below −
(5A)16 + (BF)16 = (119)16
Explanation
Start by adding the hexadecimal digits in the rightmost column: A + F = 10 + 15 = 25 = 16 + 9. Here, 16 forms a carry to the next column. Thus, the sum is 9 with a 1 as carry to the next column.
Move to the next column and add the digits along with carry: 5 + B + 1 = 5 + 11 + 1 = 17 = 16 + 1. Here, 16 forms a carry to the next column. Thus, the sum is 1 with a carry 1. There are no digits left, hence carry will also be written as leftmost digit in the sum.
So, the hexadecimal sum of 5A and BF is 119.
Example 2
Add (ABC)16 and (2A9)16.
Solution
The hexadecimal sum of given numbers is shown below −
(ABC)16 + (2A9)16 = (D65)16
Explanation
Start by adding the digits in the rightmost column: C + 9 = 12 + 9 = 21 = 16 + 1. Here, 16 forms a carry. Thus, the sum is 1 with a carry 1.
Move to the next column and add the digits along with the carry from the previous step: B + A + 1 = 11 + 10 + 1 = 22 = 16 + 6. Thus, the sum is 6 with a carry 1 to the next column.
Move to the leftmost column and add the digits along with the carry from the previous step: A + 2 + 1 = 10 + 2 + 1 = 13. Since, the sum is 13 which is less than 16, hence no carry is generated. In hexadecimal number system, 13 is represented by the letter D.
Hence, the hexadecimal sum of ABC and 2A9 = D65.
This is all about hexadecimal addition that involves the addition of digits of the given hexadecimal numbers column by column. The most important point to keep in mind while performing hexadecimal addition is that a carry is generated to the next column when the sum in a particular column is greater than or equal to 16, i.e., base of the hexadecimal number system.
Hexadecimal Subtraction
Hexadecimal subtraction is a basic arithmetic operation performed on hexadecimal numbers to determine the difference between them.
Hexadecimal subtraction is similar to decimal subtraction. The only difference is that in hexadecimal subtraction, when the minuend digit is smaller than the subtrahend digit, a borrow 1, which is equivalent to 16, is taken from the higher column digit.
Let us understand the hexadecimal subtraction with the help of solved examples.
Example 1
Subtract (125)16 from (A57)16.
Solution
The subtraction of given hexadecimal numbers is given below −
(A57)16 – (125)16 = (932)16
Explanation
Start subtracting the hexadecimal digits from rightmost column: 7 – 5 = 2. Write down the result.
Move to the next column and subtract the digits: 5 – 2 = 3. Write down the digit 3 as difference.
Move to the leftmost column and subtract the digits: A – 1 = 10 – 1 = 9. Write down the result as difference.
So, the hexadecimal difference of A57 and 125 is 932.
Example 2
Subtract (1DA)16 from (BC5)16.
Solution
The hexadecimal subtraction of BC5 and 1DA is shown below −
(BC5)16 – (1DA)16 = (9EB)16
Explanation
Start by subtracting from the digits in rightmost column: 5 – A. Since 5 is less than A (10), so we have to borrow from the next higher-order digit. After borrowing from the next column (C), the digit 5 will become 5 + 16 (as 16 is equivalent to borrow 1) = 21. Thus, 21 – A = 11 (B). Write down B as the difference.
Move to the next column and subtract the digits: B – D. Again, B is smaller than D, so we take a borrow from the higher order digit B. After getting a borrow, B will become B + 16 = 27. Thus, 27 – D = 14 (E). Write down the digit E as difference.
Move to the leftmost column and subtract the digits: A – 1 = 9. Write down the result.
Hence, the hexadecimal difference of BC5 and 1DA is equal to 9EB.
These examples explain the process of subtracting two hexadecimal numbers. Let us now discuss the third basic arithmetic operation on hexadecimal numbers i.e., hexadecimal multiplications.
Hexadecimal Multiplication
Hexadecimal multiplication is an arithmetic operation used to determine the product of two hexadecimal numbers.
Hexadecimal multiplication is similar to the decimal multiplication. But, in the case of hexadecimal multiplication, a carry is generated to the next column when the product is greater than or equal to 16.
The following examples demonstrate the process of multiplying two hexadecimal numbers.
Example 1
Multiply (A19)16 by (B)16.
Solution
The multiplication of given hexadecimal numbers is shown below −
(A19)16 times (B)16 = (6F13)16
Explanation
Multiply the digit (B)16 with each digit of the number (A19)16 and write down the result.
Firstly, we multiply B by 9, it gives 99 = 96 + 3. Hence, 3 is written as product and 96 as carry 6 (16 × 6 = 96) to the next column.
Then, we multiply B by 1 and add the carry 6 to the product. It gives 17 = 16 + 1. Here, the result is 1 and carry is 1.
Finally, we multiply B by A and add the carry 1 overed from previous step to product. It gives 96 + 15 (F in hexadecimal). The result is F with a carry 6.
Thus, the final hexadecimal product of A19 and B is 6F13.
Example 2
Multiply (ABC)16 by (29)16.
Solution
The multiplication of given hexadecimal numbers is shown below −
(ABC)16 times (29)16 = (1B81C)16
Explanation
In this example, we first multiply the digit (9)16 of the second number (29)16 by each digit of the number (ABC)16. Write down the partial product.
Then, we multiply the digit (2)16 of the number (29)16 by each digit of the number (ABC)16. Write down the partial product by shifting one position to the left.
Finally, we sum up all the partial products to obtain the final result.
Thus, the hexadecimal product of (ABC)16 and (29)16 is (1B81C)16.
Hexadecimal Division
Hexadecimal division is the fourth basic arithmetic operation that we perform on base-16 numbers. In the hexadecimal division, we obtain two results namely, quotient and remainder.
The following steps are to be followed to perform the hexadecimal division −
- Step 1 − Start diving from the leftmost digit of the dividend.
- Step 2 − Multiply the obtained quotient by the divisor and subtract from the dividend.
- Step 3 − Bring down the next significant digit or digits of the dividend.
- Step 4 − Repeat the process explained in the above three steps until all the digits in the dividend are used.
The following examples demonstrate the process of performing hexadecimal division.
Example 1
Divide (A29)16 by (5)16.
Solution
The hexadecimal division of A29 by 5 is given below −
In this hexadecimal division, we have obtained the quotient (208)16 and remainder (1)16.
Example 2
Divide (1AC)16 by (A)16.
Solution
The hexadecimal division of given numbers is shown below −
In this example, we obtained the quotient (2A)16 and the remainder (8)16.
We explained the direct method of performing hexadecimal arithmetic operations. Now let”s see how we can perform all these four hexadecimal arithmetic operations through binary arithmetic.
As we know, each hexadecimal digit can be represented as group of four bits as shown in the following table.
Hexadecimal | Binary |
---|---|
0 | 0000 |
1 | 0001 |
2 | 0010 |
3 | 0011 |
4 | 0100 |
5 | 0101 |
6 | 0110 |
7 | 0111 |
8 | 1000 |
9 | 1001 |
A | 1010 |
B | 1011 |
C | 1100 |
D | 1101 |
E | 1110 |
F | 1111 |
Let us now discuss hexadecimal arithmetic operations through binary conversion.
Hexadecimal Addition Through Binary Conversion
In this method of adding two hexadecimal numbers, we first convert them to their equivalent binary format, then add the obtained binary numbers using rules of binary arithmetic, and finally convert the final result back to the hexadecimal format.
The following example demonstrates the process of hexadecimal addition through binary conversion.
Example
Add (A5C)16 and (CCD)16 through binary conversion.
Solution
Converting the given hexadecimal numbers to their binary equivalent,
(A5C)16 = (1010 0101 1100)2
(CCD)16 = (1100 1100 1101)2
Adding the obtained binary numbers,
Finally, converting the binary sum to its equivalent hexadecimal format to obtain the final result.
(0001 0111 0010 1001)2 = (1729)16
Hence, the hexadecimal sum of (A5C)16 and (CCD)16 is (1729)16.
Hexadecimal Subtraction Through Binary Conversion
To subtract two hexadecimal numbers through binary conversion, we first convert the given hexadecimal numbers to their binary equivalent. Then, subtract them as per the rules of binary arithmetic. Finally, convert the final result back to the hexadecimal format.
Here is an example demonstrating the process of hexadecimal subtraction through binary conversion.
Example
Subtract (AC2)16 from (FEA)16 using binary arithmetic.
Solution
Converting the given hexadecimal numbers to their binary equivalent,
(FEA)16 = (1111 1110 1010)2
(AC2)16 = (1010 1100 0010)2
Subtracting the obtained binary numbers,
Converting the difference back to the hexadecimal to obtain the final result,
(0101 0010 1000)2 = (528)16
Hence, the hexadecimal difference of (FEA)16 and (AC2)16 is (528)16.
Hexadecimal Multiplication Through Binary Conversion
We can also multiply two hexadecimal numbers by converting them into their binary equivalent. For this, we first convert the given hexadecimal numbers to their binary equivalent, then multiply the binary numbers as per the rules of binary arithmetic, and convert the result back to hexadecimal to obtain the final result.
The following example demonstrates the process of multiplying hexadecimal numbers through binary conversion.
Example
Multiply (A9C)16 by (B)16 through binary conversion.
Solution
Converting the given hexadecimal numbers to their equivalent binary,
(A9C)16 = (1010 1001 1100)2
(B)16 = (1011)2
Multiplying the binary numbers,
Converting the product back to the hexadecimal format,
(0111 0100 1011 0100)2 = (74B4)16
Thus, the hexadecimal product of A9C and B is 74B4.
Hexadecimal Division Through Binary Conversion
The hexadecimal division can also be performed using binary arithmetic. In this method, firstly, we convert the given hexadecimal numbers to their binary equivalent and then divide them as per the rules of binary division. At the end, we convert the result from binary format to hexadecimal to obtain the final result.
Let us understand the hexadecimal division using binary arithmetic with the help of an example.
Example
Divide (AB8)16 by (A)16 using binary arithmetic.
Solution
Converting the given hexadecimal numbers to their binary equivalent,
(AB8)16 = (1010 1011 1000)2
(A)16 = (1010)2
Dividing the obtained binary numbers,
Converting the quotient and remainder to hexadecimal,
Quotient = (0001 0001 0010)2 = (112)16
Remainder = (0100)2 = (4)16
Conclusion
In this chapter, we explained the four basic arithmetic operations (addition, subtraction, multiplication, and division) of hexadecimal numbers. We also discussed the binary method of hexadecimal arithmetic operations.
”;