Bifalgorithm post · Brisk · Chapter 1

How do you add hexadecimal numbers directly?

How do you add hexadecimal numbers directly? (Brisk · Chapter 1) — "Suppose we have two hexadecimal numbers, and we want to add them together to get a hexadeci…

Ideas in this flowchart

  • L’addition hexadécimale peut se faire directement, chiffre par chiffre, de droite à gauche.
  • Méthode alternative : convertir les nombres en décimal, les additionner, puis reconvertir le résultat en hexadécimal.
  • Méthode native : additionner chaque paire de chiffres en respectant les valeurs hexadécimales.
  • Exemple : additionner 48D4₁₆ et 5925₁₆.
  • La procédure suit la méthode scolaire, en commençant par le chiffre le plus à droite.
  • Pour une somme inconnue, compter les positions hexadécimales successives permet de trouver le résultat.
  • Unités : 4 + 5 = 9, donc le chiffre de droite est 9.
  • Chiffre suivant : D + 2 = F, en comptant E puis F.
  • Chiffre suivant : 8 + 9 = 11₁₆ ; on écrit 1 et on reporte 1.
  • Dernier chiffre : 4 + 5 + 1 reporté = A, sans nouveau report.
  • Résultat final : 48D4₁₆ + 5925₁₆ = A1F9₁₆.
Feed/

How do you add hexadecimal numbers directly?

Channel

Brisk

1 page

"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."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.