Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 38 ยท Integers and Rational Numbers

Integers and the Number Line

Meet negative numbers: learn integers, how to place and compare them on a number line, opposites and absolute value, with real-life examples and code.

Whole numbers cannot describe everything. A freezer at 18 degrees below zero, a bank account that is 40 dollars overdrawn, a diver 12 meters under the surface: these need numbers on the other side of zero. Integers include the whole numbers, their negatives and zero:

..., โˆ’3, โˆ’2, โˆ’1, 0, 1, 2, 3, ...

Numbers greater than zero are positive; numbers less than zero are negative. Zero is neither. A negative sign is written with a minus sign directly in front of the number: โˆ’7 is read "negative seven".

Integers in real life

Situation Integer
5 degrees Celsius below freezing โˆ’5
Gaining 8 points in a game +8
A diver at 12 m below sea level โˆ’12
Withdrawing 30 dollars โˆ’30
3rd floor above ground 3
2nd basement floor โˆ’2

Notice that the sign gives direction and the number gives size.

The number line

A number line is a straight line with equally spaced marks. Zero is the origin. Positive numbers are to the right, negatives to the left.

flowchart LR
    A["-3"] --- B["-2"] --- C["-1"] --- D["0"] --- E["1"] --- F["2"] --- G["3"]

Numbers increase to the right and decrease to the left.

On a number line, a number is always greater than every number to its left. That gives the key rule for comparing integers:

  • Any positive number is greater than any negative number: 2 > โˆ’100.
  • Zero is greater than every negative number: 0 > โˆ’4.
  • Among negatives, the one closer to zero is greater: โˆ’2 > โˆ’9. Think of temperature: โˆ’2 ยฐC is warmer than โˆ’9 ยฐC.
Python Compare and sort integers

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.

Opposites

Two numbers the same distance from zero on opposite sides are opposites: 5 and โˆ’5. The opposite of 0 is 0. Writing a minus sign in front of a number takes its opposite: โˆ’(5) = โˆ’5, and โˆ’(โˆ’5) = 5. The opposite of the opposite is the number itself.

Absolute value

The absolute value of a number is its distance from zero on the number line. Distance is never negative. We write it with vertical bars:

  • |7| = 7
  • |โˆ’7| = 7
  • |0| = 0

So opposites have the same absolute value. Absolute value ignores direction and keeps only size.

Python Absolute value and distance from zero

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.

A larger absolute value does not mean a larger number when the number is negative. |โˆ’9| = 9 is bigger than |4| = 4, but โˆ’9 < 4.

Distance between two numbers

The distance between two points on a number line is the absolute value of their difference. Between โˆ’3 and 5: |5 โˆ’ (โˆ’3)| = |8| = 8. You can also count steps: 3 steps from โˆ’3 to 0, then 5 more steps to 5, total 8. (Subtracting negatives is the topic of the next lesson.)

Python Distance between two integers

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.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which list is in order from least to greatest?

    โˆ’5 is farthest left, then โˆ’1, then 0, then 3.
  2. 2. What is |โˆ’15|?

    Absolute value is distance from zero, which is always non-negative.
  3. 3. Which statement is true?

    โˆ’6 is to the left of โˆ’1, so โˆ’6 < โˆ’1. Among negatives, the number nearer zero is greater.
  4. 4. What is the distance between โˆ’4 and 6 on the number line?

    |6 โˆ’ (โˆ’4)| = |10| = 10. Distance is never negative.

Summary

  • Integers are the whole numbers, their negatives and zero.
  • On a number line, numbers increase to the right; compare by position.
  • Opposites are the same distance from zero on opposite sides.
  • Absolute value is the distance from zero, so it is never negative.
  • Distance between two numbers is the absolute value of their difference.

Next: Adding and Subtracting Integers