Difference between revisions of "Alternative Base Addition"

From Coder Merlin
Line 80: Line 80:
|}
|}


=== 104 + 397 ===
=== <math>104_{10} + 397_{10}</math> ===
{|
{|
|style="width: 70%;" | To add <math>104 + 397</math> we:
|style="width: 70%;" | To add <math>104_{10} + 397_{10}</math> we:
* Align the digits vertically
* Align the digits vertically
* Add the right-most column, containing 4 and 7, yielding 11.  Because this is greater than the quantity that can be represented by a single digit, we  carry.
* Add the right-most column, containing 4 and 7, yielding 11.  Because this is greater than the quantity that can be represented by a single digit, we  carry.

Revision as of 10:11, 19 July 2019

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
1 + 1 = 10
Dark apple
Dark apple

Prerequisites[edit]

Addition (Decimal System)[edit]

Addition is a basic (and critical) operation. Important properties of addition include:

  • Addition is commutative, meaning that the order of the operands does not matter
  • Addition is associative, meaning that when we're adding more than two operands, the order that we perform the addition does not matter
  • The identity element for addition, also termed the additive identity, is zero
  • The operator for addition is the plus () sign
  • The operands for addition are called addends

Let's review how we perform addition in the number system with which we are most familiar, the decimal system.

There are a few simple rules when adding non-negative, whole numbers:

  1. Align the addends vertically, flush right. (This step ensures that the position multiplier is the same for both addends in each column.)
  2. If any addend has fewer digits than the addend with the maximum digits, we may place a zero in columns to the left of the existing addend. (Leading zeroes don't impact the value.)
  3. Starting from the right-most column, add the two digits of the addend and the carry. Note that this means that we are adding three operands in each column. If the sum exceeds the quantity that can be represented with a single digit, carry a one to the column to the left.
  4. Repeat the process with the column to the left until reaching the final column.

Let's look at a few examples:

[edit]

To add we:
  • Align the digits vertically
  • Add the right-most (and only) column, containing a 3 and a 5, yielding 8. Because this is less than the quantity that can be represented by a single digit, we have no carry.
  • Done
carry 0 0
addend 0 3
addend 0 5
sum 0 8

[edit]

To add we:
  • Align the digits vertically
  • Add the right-most column, containing a 3 and an 8, yielding 11. Because this is greater than the quantity that can be represented by a single digit, we carry.
  • We move to the left, where the next column contains only a lone value, the carry. We sum this with the addend digits in the same column, yielding 1.
  • Done
carry 1 0
addend 0 3
addend 0 8
sum 1 1

[edit]

To add we:
  • Align the digits vertically
  • Add the right-most column, containing 4 and 7, yielding 11. Because this is greater than the quantity that can be represented by a single digit, we carry.
  • We move to the left, where the next column contains the carry and a 9, yielding 10. Because this is greater than the quantity that can be represented by a single digit, we carry.
  • We move to the left, where the next column contains the carry, a 1, and a 3, yielding 5. Because this is less than the quantity that can be represented by a single digit, we have no carry.
  • Done
carry 1 1 0
addend 1 0 4
addend 3 9 7
sum 5 0 1

Addition (Octal System)[edit]

There's no need for any additional rules for the octal system. In fact, for all systems, the rules are exactly the same! Let's get right to an example:

[edit]

To add we:
  • Align the digits vertically
  • Add the right-most column, containing 4 and 7, yielding 11. Because this is greater than the quantity that can be represented by a single digit, we carry.
  • We move to the left, where the next column contains the carry and a 9, yielding 10. Because this is greater than the quantity that can be represented by a single digit, we carry.
  • We move to the left, where the next column contains the carry, a 1, and a 3, yielding 5. Because this is less than the quantity that can be represented by a single digit, we have no carry.
  • Done
carry 1 1 0
addend 1 0 4
addend 3 9 7
sum 5 0 1

Key Concepts[edit]

Exercises[edit]

References[edit]