Author: Jeffrey Pan

In a previous blog, I talked about hexadecimal and the symbols used to represent numbers in it. Today, I will be explaining how to add and subtract hexadecimal numbers or hex for short. I will be only be dealing with positive numbers as negatives numbers are very complicated in both binary and hexadecimal. Now lets get started!

Adding in hex is very similar to binary. First, you set it up like you are adding base ten numbers in math class. Then, you add the right most digits. If those two digits add up to more than 16, subtract 16 from that number and add one to the digit to the left. Repeat until the number is added out. I have shown an example below:

Add B4 and FO in base 16

B4 (180 in base 10) +FO (240 in base 10) 1A4 (420 in base 10) As you can see (B+F is 26. 26-16 is 10 or A)

Subtraction in hex is also very similar to subtraction in binary. First you set the equation up like above, but you use a subtraction sign instead of addition. Then you subtract the right-most digits. If the digit being subtracted is larger than the one above, you “borrow” one from the digit to the left which increases the value that you found by 16.

Subtract 1F from 7A in base 16

7A (122 in base 10) -1F (31 in base 10) 5B (91 base 10)

If you want to check your answers, convert all numbers to base 10 and add or subtract them. If you need more practice, here are some more questions below. Answers are posted under the Youtube video.

Add 8F and F9

Add ABC and 159

Add 123, 456, and 789

Subtract 5D from 8A

Subtract 5DC from 7FA

Subtract ABC and 598 from 1F0D

If you are still confused, please watch this Youtube video. Ignore the part where he put 8+B = 13.

As said before in an earlier post, numbers are calculated in different bases. The most used types are base two (also known as binary), base 10 (which we use mainly in mathematics), and hexadecimal, which is what we will be learning about today. As you know, there are no symbols to represent numbers that are 10 or up. So here are the following shortcuts that are used in hexadecimal.

For numbers 0-9, use the regular 0-9

For the number 10 – use the symbol A

For the number 11 – use the symbol B

For the number 12 – use the symbol C

For the number 13 – use the symbol D

For the number 14 – use the symbol E

For the number 15 – use the symbol F

For example, numbers can look like 17F, 7B9, ABC, and much much more.

So why is hexadecimal used? Hexadecimal is used as a simplification of binary. For example:

In binary, 289 is represented as 0001 0010 0001

In hexadecimal, 289 is represented as 121

As you can see, it is much easier to use hexadecimal than to use binary.

Now lets talk about the relation between binary and hexadecimal. As you know, each binary digit is known as a bit (0101 has 4 bits). Eight of these is known as a byte (0100 0111). Lastly, a nibble is four bits (0101), which hexadecimal uses. Converting from binary to hexadecimal, every nibble is one digit in hexadecimal. Here is one example shown:

Convert 1011100 to Hexadecimal:

0101 1100 First, split the binary number into different nibbles

5 12 Convert these nibbles into base 10 numbers

5C Convert the base 10 numbers to hexadecimal

Here are some practice problems. Answers to these are under the Youtube video.

Convert 0010 1010 1010 from binary to hexadecimal

Convert 0010 1011 from binary to hexadecimal

Convert 1010100 from binary to hexadecimal

Convert 111001011 from binary to hexadecimal

Convert 50 base ten to hexadecimal (Convert to binary first)

Convert 829 base ten to hexadecimal

If your are still having trouble understanding this, please use this Khan Academy video that explains the concept pretty well.