Number Line Distance Calculator
Find how far apart two numbers are on the number line. Enter any two values — whole numbers, decimals, or fractions like 3/4 — and get the distance |a − b| with a picture and step-by-step working.
What does distance on a number line mean?
A number line is just a straight line with zero in the middle, positive numbers stretching to the right, and negative numbers stretching to the left. Every number lives at one exact spot on that line.
The distance between two numbers is how many units you'd have to walk along the line to get from one to the other. If you're at 3 and your friend is at 7, you'd walk 4 steps to reach them. Distance = 4.
It doesn't matter whether you walk left-to-right or right-to-left — the number of steps is the same. That's why distance never depends on which number comes first.
Number-line distance, piece by piece
The distance between two numbers is |a − b| — the absolute value of their difference. The cards below cover the three cases you actually run into, plus the sign traps that make this seem harder than it is.
Two positive numbers
Just count the steps from one to the other. |a − b| strips any sign the subtraction leaves behind.
Signs mixed or both negative
Subtracting a negative flips it to plus: a − (−b) = a + b. Write it out fully before you take the absolute value.
Sign traps and order
Distance never goes negative — if you got a negative answer, you forgot the bars. And |a − b| always equals |b − a|, so input order does not matter.
Features of this calculator
- Accepts integers ("7"), decimals ("2.5") and fractions ("3/4" or "-5/2") in either input
- Works with positive numbers, negative numbers, and any mix of the two
- Draws a labelled number line with both points and the distance bracketed between them
- Shows every step: setting up |a − b|, substituting the numbers, and taking the absolute value
- Handles the case where both numbers are the same (distance = 0) cleanly
- No sign confusion — the order you enter the numbers doesn't change the answer
Frequently asked questions
+Why can't distance be negative?
Distance is a length — how far apart two things are. Lengths are always zero or positive. A negative subtraction result tells you the direction (which one is bigger), but the absolute value bars strip that sign away and leave just the length.
+How does this relate to absolute value equations?
An equation like |x − 3| = 5 asks: "which numbers are exactly 5 units away from 3 on the number line?" There are two answers, one on each side: x = 8 and x = −2. This calculator does the reverse — you give it the two numbers, and it tells you the distance.
+Does this work for fractions and decimals?
Yes. Enter a decimal like 2.75 or a fraction like 3/4 in either input. The calculator converts fractions to decimals for the arithmetic and reports the distance.
+What if I enter the same number twice?
The distance is 0 — the two points are actually the same point on the number line, so there's nothing to walk.