Concept
How do you add hexadecimal numbers directly?
Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk / Chapter 1
"Suppose we have two hexadecimal numbers, and we want to add them together to get a hexadecimal result. How do we do it? One way is to first convert them both to decimal, then add them like you learned in first grade, then convert the answer back to hex. But we can stay “natively hex” as long as we add each pair of digits correctly. Let’s try it. Suppose we want to compute this sum: 48D4_16 + 5925_16. We proceed in the first-grade way from right to left. Adding the one’s-place values, we get 4 + 5 = 9, so the rightmost digit is 9. Now we add the next digit to the left (the sixteen’s-place, mind you, not the ten’s place) and we find D + 2. Now what in the world is “D+2”? It’s actually easy: all you have to do is the same thing you did when you were a child and you had to add something like 4 + 5. You hadn’t memorized the answer yet, and so you started with four fingers held up, and counted off “1…2…3…4…5,” sticking up another finger each time. Then, you looked at your hands, and behold! nine fingers. We’ll do the same thing here: start with the number “D,” and count two additional places: “E…F.” The answer is F. That is the number that’s two greater than D. Lucky for us, it still fits in one digit. So far we have F9. The next pair of digits is 8 + 9. Here’s where you want to be careful. You’re liable to look at “8+9” and immediately say “17!” But 8 + 9 is not 17 in hexadecimal. To figure out what it is, we start with the number 8, and count: “9…A…B…C…D…E…F…10…11…”. The answer is “11,” which of course is how you write “seventeen” in hex. So just like in grade school, we write down 1 and carry the 1. Finally, our last digit is 4 + 5, plus the carried 1. We start with four and count off five: “5…6…7…8…9.” Then we add the carry, and count “…A.” The answer is A, with no carry, and so we have our final answer: 48D4_16 + 5925_16 = A1F9_16."
Related Ideas
- How do you add binary numbers?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- Why is hexadecimal used in computer science, and what do its digits represent?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How does a base determine the symbols and place values used to represent numbers?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How are numbers interpreted in a base 7 system?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How do place values and counting work in binary?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How do you convert between binary and hexadecimal using nibbles?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How much information can one or more bytes store?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1
- How can you quickly judge whether a base-conversion claim is impossible?Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk · Chapter 1