zaro

How to Do a Subtraction Algorithm?

Published in Math Algorithms 2 mins read

The subtraction algorithm is a step-by-step process to find the difference between two numbers. Here's how it works:

1. Setting Up the Problem

  • Write the larger number (minuend) above the smaller number (subtrahend). This is your "top number" and "bottom number" as mentioned in the reference.
  • Align the numbers vertically by place value (ones, tens, hundreds, etc.). This is crucial for accurate calculations.

2. Simple Subtraction (No Borrowing Needed)

  • If each digit in the bottom number is less than or equal to the digit directly above it in the top number, simply subtract in each column, starting from the rightmost column (ones place).

    Example:

      578
    - 231
    ------
      347
    • 8 - 1 = 7
    • 7 - 3 = 4
    • 5 - 2 = 3

3. Subtraction with Borrowing (Regrouping)

  • If a digit in the bottom number is larger than the digit directly above it in the top number, you'll need to "borrow" from the digit to the left.

    Example:

      423
    - 156
    ------
    • You can't subtract 6 from 3, so you need to borrow from the tens place.
    • The 2 in the tens place becomes a 1, and the 3 in the ones place becomes 13 (10 + 3).
      4 1 13
    - 1 5  6
    -------
    • Now, subtract: 13 - 6 = 7
    • Next, you can't subtract 5 from 1, so borrow from the hundreds place. The 4 becomes a 3, and the 1 in the tens place becomes 11.
      3 11 13
    - 1  5  6
    -------
    • 11 - 5 = 6
    • 3 - 1 = 2
      3 11 13
    - 1  5  6
    -------
      2  6  7
    • Therefore, 423 - 156 = 267

4. Borrowing Across Zeros

  • If you need to borrow from a place value that contains a zero, you need to borrow from the next non-zero digit to the left.

    Example:

      503
    - 245
    ------
    • You can't subtract 5 from 3, and you can't borrow from the tens place because it's a zero. You need to borrow from the hundreds place.
    • The 5 becomes a 4. The zero in the tens place becomes a 10. Then you borrow 1 from the 10 making it 9 and giving you 13 in the ones column.
      4 9 13
    - 2 4  5
    -------
    • Now subtract: 13 - 5 = 8
    • 9 - 4 = 5
    • 4 - 2 = 2
      4 9 13
    - 2 4  5
    -------
      2 5  8
    • Therefore, 503 - 245 = 258

Summary

The subtraction algorithm involves aligning numbers by place value, subtracting column by column from right to left, and borrowing (regrouping) when a digit in the bottom number is larger than the digit above it. It's crucial to understand borrowing across zeros.