Math

Absolute Value Calculator

Enter any number to find its absolute value, or switch to find the distance between two numbers.

FreePrivateFormula explained

Your result

Did our calculator solve your problem?

The absolute value of a number is how far it’s from zero, ignoring direction. It’s written with two vertical bars, so |-7.5| = 7.5.

The same idea gives you the distance between any two numbers, and that’s why it keeps turning up in geometry, statistics and code.

How to use the Absolute Value Calculator#

  1. Choose a mode. Pick a single absolute value or a distance.
  2. Enter your number. Negative numbers are fine.
  3. Read the result. The absolute value is always zero or positive.

The definition#

|x| = x if x ≥ 0, and |x| = −x if x < 0

If the number is already positive or zero, it stays the same. If it’s negative, you drop the minus sign. So |12| = 12 and |-12| = 12.

Distance between two numbers#

Distance = |x − y|

The distance between -4 and 3 on the number line is |-4 − 3| = 7. Order doesn’t matter, because |3 − (-4)| is also 7.

Where it’s used#

Absolute values appear in error measures, like the absolute error in the percent error calculator. They’re used in solving equations like |x − 2| = 5, which has two answers, 7 and -3, and in programming, where an abs function is standard.

Absolute value as distance#

The absolute value of a number is its distance from zero on the number line, and distance is never negative. That is why |−7| and |7| are both 7. The same idea gives the distance between two numbers: |x − y| is how far apart they are, whichever one is larger. The distance from −3 to 5 is |−3 − 5| = |−8| = 8.

Zero has an absolute value of zero, and it is the only number for which that is true. Every other number has a positive absolute value.

Equations and inequalities#

Absolute values appear in equations like |x − 3| = 5. This means x is 5 units away from 3, so x = 8 or x = −2. For an inequality such as |x| < 4, x has to be less than 4 units from zero, so −4 < x < 4. For |x| > 4, x is more than 4 units away, so x < −4 or x > 4. Solving these means splitting the problem into two cases, one for a positive inside and one for a negative inside.

ExpressionValueWhy
|−12|1212 units from zero
|3 − 10|7|−7| = 7
−|5|−5The minus sign is outside the bars
|−2 × 6|12Work out the inside first
|0|0Zero is its own opposite

In spreadsheets and code#

The function exists nearly everywhere: ABS() in Excel and Google Sheets, abs() in Python, Math.abs() in JavaScript and fabs() or abs() in C. A piecewise definition says the same thing as the formula: |x| equals x when x is zero or positive, and −x when x is negative. The graph of y = |x| is a V with its point at the origin. Programmers use it to compare numbers with a tolerance, for example to check that two decimals are close enough by testing whether |a − b| is under 0.0001.

Two rules, and absolute value inequalities#

The absolute value of a product is the product of the absolute values: |a × b| = |a| × |b|. So |−3 × 4| = 12 and |−3| × |4| = 12. But the absolute value of a sum is not the sum of the absolute values. The triangle inequality says |a + b| ≤ |a| + |b|, with equality only when a and b have the same sign. With a = −3 and b = 4, |a + b| = 1, while |a| + |b| = 7. Many algebra mistakes come from treating the bars as brackets that simply drop minus signs.

ab|a + b||a| + |b|
3477
−3417
−3−477
5−5010

Inequalities work too. To solve |x − 3| < 2, ask which numbers are less than 2 away from 3. The answer is every x between 1 and 5. In real life, absolute values show up whenever direction does not matter, such as the size of an error, a temperature change or the distance between two towns on a road.

Frequently asked questions#

The same number without the minus sign.

Zero.

No. It’s always zero or positive.

x can be 5 or -5.

Subtract one from the other and take the absolute value. The distance between 4 and −6 is |4 − (−6)| = |10| = 10. It does not matter which number you subtract from the other, because |x − y| and |y − x| are equal. Use the second mode of the calculator and enter both numbers.

More calculators