Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 38 ยท Integers and Rational Numbers

Adding and Subtracting Integers

Learn clear rules for adding and subtracting positive and negative integers using the number line, with worked examples, common mistakes and code.

Adding and subtracting with negative numbers feels strange at first, but it follows simple, consistent rules. The easiest picture is walking on a number line: a positive number means "move right", a negative number means "move left".

Adding integers on the number line

To compute a + b, start at a, then move |b| steps right if b is positive and left if b is negative.

  • 3 + 4: start at 3, move 4 right โ†’ 7.
  • 3 + (โˆ’5): start at 3, move 5 left โ†’ โˆ’2.
  • โˆ’2 + (โˆ’4): start at โˆ’2, move 4 left โ†’ โˆ’6.
  • โˆ’6 + 9: start at โˆ’6, move 9 right โ†’ 3.

The rules for addition

  1. Same signs: add the absolute values and keep the sign. (โˆ’4) + (โˆ’3) = โˆ’7.
  2. Different signs: subtract the smaller absolute value from the larger, and keep the sign of the number with the larger absolute value. (โˆ’9) + 5: 9 โˆ’ 5 = 4, and 9 is negative, so โˆ’4.
  3. Opposites add to zero: 6 + (โˆ’6) = 0.

A helpful model uses chips: each positive chip cancels one negative chip. In (โˆ’9) + 5, five pairs cancel and four negative chips remain: โˆ’4.

Python Adding integers with rules

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The function follows the rules exactly, and the last column checks it against the built-in +.

Subtracting integers

Subtracting a number is the same as adding its opposite:

a โˆ’ b = a + (โˆ’b)

  • 7 โˆ’ 3 = 7 + (โˆ’3) = 4
  • 7 โˆ’ (โˆ’3) = 7 + 3 = 10
  • โˆ’5 โˆ’ 4 = โˆ’5 + (โˆ’4) = โˆ’9
  • โˆ’5 โˆ’ (โˆ’4) = โˆ’5 + 4 = โˆ’1

Why is 7 โˆ’ (โˆ’3) = 10? Think of a temperature of 7 degrees. Removing 3 degrees of "cold" (โˆ’3) makes it warmer. Another way: the distance from โˆ’3 up to 7 is 10, and subtraction finds the gap between numbers.

Rewrite every subtraction as an addition of the opposite: change โˆ’ to + and flip the sign of the second number. Then use the addition rules.

Python Subtraction as adding the opposite

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Several terms at once

Evaluate โˆ’8 + 12 โˆ’ 5 โˆ’ (โˆ’3) from left to right after rewriting:

โˆ’8 + 12 + (โˆ’5) + 3

  • โˆ’8 + 12 = 4
  • 4 + (โˆ’5) = โˆ’1
  • โˆ’1 + 3 = 2

You may also group positives and negatives: positives 12 + 3 = 15, negatives โˆ’8 โˆ’ 5 = โˆ’13, total 15 โˆ’ 13 = 2. The commutative and associative properties make that legal.

Real-world example: elevation

A hiker starts at 40 m above sea level and descends 55 m. The new elevation is 40 โˆ’ 55 = 40 + (โˆ’55) = โˆ’15 m, meaning 15 m below sea level. A submarine at โˆ’120 m that rises 45 m ends at โˆ’120 + 45 = โˆ’75 m.

Python Track a running total

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common mistakes

  • Reading 3 โˆ’ 5 as 5 โˆ’ 3. The answer is โˆ’2, not 2.
  • Forgetting that โˆ’ (โˆ’4) becomes + 4.
  • Treating a double sign as two minuses that make nothing. โˆ’(โˆ’4) equals +4; the signs combine into a plus.

Writing 5 + โˆ’3 is awkward; most writers add parentheses: 5 + (โˆ’3).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is (โˆ’7) + (โˆ’5)?

    Same signs: add 7 + 5 = 12 and keep the negative sign.
  2. 2. What is 4 โˆ’ 9?

    4 โˆ’ 9 = 4 + (โˆ’9). Different signs: 9 โˆ’ 4 = 5, and 9 is negative, so โˆ’5.
  3. 3. What is โˆ’6 โˆ’ (โˆ’10)?

    Subtracting โˆ’10 is adding 10: โˆ’6 + 10 = 4.
  4. 4. A freezer is at โˆ’18 ยฐC and warms by 7 ยฐC. What is the new temperature?

    โˆ’18 + 7 = โˆ’11.

Summary

  • Add on a number line: move right for positive, left for negative.
  • Same signs: add and keep the sign. Different signs: subtract and keep the sign of the larger absolute value.
  • Subtracting equals adding the opposite: a โˆ’ b = a + (โˆ’b).
  • Rewrite subtractions as additions to avoid sign errors.

Next: Multiplying and Dividing Integers