Lelifi·tools

Absolute Value Calculator

Absolute value is distance from zero, so it is never negative. |-7.5| = 7.5 is the whole rule in one line. Two numbers 27 apart give |18 - 45| = 27, and solving |x - 5| = 3 gives x = 2 and x = 8.

Pick a mode. Empty boxes count as 0, so nothing here can throw an error.

All calculations run in your browser, nothing is uploaded.

Find the absolute value of a number, the distance between two points, or both solutions of an absolute value equation, and see how the same idea runs through tolerance bands and error checks.

By the Lelifi editors ·

Key takeaways

Both 5 units from 0-6-4-202465 units5 units-550|-5| = 5 and |5| = 5. The sign says which side of 0, the absolute value says how far.
The number 5 and the number -5 sit on opposite sides of zero but the same distance away, so both have an absolute value of 5.
A part that must land within 2 mm of 250 mm244248250252256249.2 passes253.6 failsaccept from 248 to 252target 250The test is |measured - 250| <= 2, so anything more than 2 away fails.
A part with a target of 250 mm and a tolerance of 2 mm passes from 248 to 252. The reading of 249.2 is inside the band and 253.6 is outside it.
On this page
  1. What absolute value measures
  2. Reading |x| on a number line
  3. Distance between two numbers: |a - b|
  4. Why |x - c| = d has two answers
  5. Tolerance bands: |x - target| &lt;= tol
  6. Absolute error and relative error
  7. abs() in spreadsheets, Python and JavaScript
  8. Worked examples to retype in the calculator

What absolute value measures

Absolute value answers one question: how far is this number from zero? The two vertical bars around a number, written |x|, mean the size of the number with the sign taken off. Wichita State University's math notes describe it as the distance from x to zero on a number line, and the Defense Department Education Activity geometry notes spell out the same idea: the absolute value of a real number is the distance it is from the origin on the number line.

A sign tells you which side of zero a number sits on, which is what you need when you are adding and subtracting. The absolute value tells you the size of the distance, and size is what you need when you are comparing how far apart two things are, checking a measurement against a spec, or working out the two places an equation can be solved.

Two consequences follow. An absolute value is never negative, because a distance cannot be less than zero. And a number and its opposite share one absolute value, since they sit the same distance from 0 on opposite sides.

Reading |x| on a number line

Picture a ruler with 0 in the middle. Every number sits at a point, and the absolute value is the length of the walk from 0 to that point. Move the point from -5 to 5 and the walk stays 5 units long, which is why |-5| and |5| are the same number.

The bars erase the direction. Once you take |x|, a gain and a loss of the same size look identical, which is useful in a plant inspection where a hole 0.4 mm too big and a hole 0.4 mm too small are the same problem. It is also why to be careful with absolute value on a budget: |-200| and |200| are both 200, so the bars will not tell you which side of zero you are on.

The algebra is the same idea written down. For x at or above 0, |x| is x, and for x below 0, |x| is -x. That two-case rule is the definition in formula form, and it is what a spreadsheet, a Python script, and this calculator run behind the scenes.

Distance between two numbers: |a - b|

Put two numbers on the number line and the gap between them is |a - b|. The subtraction gives a signed difference, and the absolute value turns it into a plain distance. Swap the order and the sign flips but the distance does not.

Take 18 and 45. The difference is 27 in the negative direction, so the distance is 27, and the halfway point is 31.5.

PairDifferenceDistance |a - b|Midpoint
18 and 45-272731.5
45 and 18272731.5
-6 and 4-1010-1
12 and 120012
-9 and -2-77-5.5

Two numbers that sit the same distance from 0 do not have to be the same distance from each other. |-9| is 9 and |4| is 4, so the distance between -9 and 4 is 13, while the distance between -9 and -2 is 7.

Why |x - c| = d has two answers

An equation with absolute value bars asks how far from a center point a number can sit. If a number x has to be exactly d units away from a center c, there are two places it can land: one on each side of c. So the equation |x - c| = d gives x = c - d and x = c + d, and with d above 0 those are two different numbers.

Work the center 5 and the distance 3. One answer is 5 - 3 = 2, the other is 5 + 3 = 8. Both are 3 units from 5, which is what the equation asked for, and on a number line the dots at 2 and 8 sit on either side of the center 5.

Two special cases matter. When d is 0, the two answers collapse into one, because the only number 0 units from 5 is 5 itself. When d is negative, there is no answer, since a distance cannot be less than zero, so the calculator reports no solution instead of handing back a number.

EquationAnswer 1Answer 2Why
|x - 5| = 3283 units either side of 5
|x - 5| = 05same pointdistance 0 leaves one spot
|x - 5| = -3nonenoneno negative distances
|x - 12| = 2.59.514.52.5 units either side of 12
|x - 0| = 6-66the center is zero

Tolerance bands: |x - target| &lt;= tol

The same idea drives quality control. A shop writes a target and a tolerance, and a measurement passes when it sits close enough to the target. Written with absolute value, the test is |measured - target| <= tolerance, and the passing set is a band centered on the target.

Take a shaft that must be 250 mm with a tolerance of 2 mm. The band runs from 248 to 252. A reading of 249.2 passes, because |249.2 - 250| = 1.2 and 1.2 is inside 2. A reading of 253.6 fails, because |253.6 - 250| = 3.6, which is outside the band. The signs differ (249.2 - 250 = -1.2 and 253.6 - 250 = 3.6) and the verdicts still split the way the distances do. The calculation is the same in both directions, and the sign never changes the verdict.

A part 1 mm over and a part 1 mm under are equally out of spec, and treating them differently would mean one machine looks better than it is. Metrology follows the same rule, and the NIST handbook chapter on accuracy and reliability (Boisvert, Cools and Einarsson, 2005) defines absolute error as the magnitude of the difference between a computed value and the true value, written |x - x*|.

A measurement carries uncertainty, and the NIST Technical Note 1297 terminology appendix (2026) separates the absolute value of the error from the error itself. A reading that lands on the edge of the band with a wide uncertainty can still be out of spec, so the band test tells you where the number sits, not how sure you are about it.

Absolute error and relative error

Absolute error says how many units you are off. Relative error says how big that miss is compared to the thing you measured. The NIST handbook defines absolute error as |x - x*| and relative error as |x - x*| / |x*|, the absolute error divided by the size of the true value.

Pick a part that should be 12 inches. A measurement of 12.4 gives an absolute error of |12.4 - 12| = 0.4 inches, and a relative error of 0.4 / 12 = 0.0333, which is 3.33%. Now measure a 250 mm shaft at 248.6. The absolute error is |248.6 - 250| = 1.4 mm, and the relative error is 1.4 / 250 = 0.0056, which is 0.56%.

The 1.4 mm miss looks larger than the 0.4 inch miss, and the relative numbers show why that is misleading. A tenth of an inch is a bigger share of 12 inches than a millimeter and a half is of 250 mm.

MeasurementTrue valueAbsolute errorRelative error
12.4 in12 in0.4 in3.33%
248.6 mm250 mm1.4 mm0.56%
19.4 in20 in0.6 in3.00%
1.02 kg1.00 kg0.02 kg2.00%

Relative error has one weakness, and the NIST chapter points at it. When the true value sits near zero, the relative error blows up even though the absolute error is tiny, so a 0.001 miss on a true value of 0.01 is 10% relative error. Near zero, quote the absolute number.

abs() in spreadsheets, Python and JavaScript

Every tool you use daily has the same function under a shorter name, and they all do one thing: drop the sign.

WhereCallResult for -7.5
Excel and Google Sheets=ABS(A1)7.5
Pythonabs(-7.5)7.5
JavaScriptMath.abs(-7.5)7.5
SQLABS(-7.5)7.5
Excel, text version=ABS(-7.5)7.5

Two habits pay off. Feed ABS a cell rather than a typed number, so the check keeps working when the measurement changes. And when you need the direction as well as the size, keep the signed difference in one cell and the absolute value in another, and read both.

That second habit is where the site's absolute change calculator fits: it handles the new minus old comparison and the percentage that goes with it. The tool on this page stays on the sign and the distance.

Worked examples to retype in the calculator

Three short examples cover most of what people ask for. Type them in and compare the output with the numbers here.

One: the absolute value of a single number. Enter -7.5 in the first box. The result is 7.5, and the calculator notes that the opposite number 7.5 has the same absolute value. A positive input of 7.5 gives 7.5 as well.

Two: the distance between two points. Switch to the distance mode and enter 18 and 45. The distance is 27 and the midpoint is 31.5. Swapping the boxes gives 27 again, a quick check that you entered the pair the way you meant to.

Three: solving an absolute value equation. Switch to the equation mode, enter a center of 5 and a distance of 3. The two solutions are 2 and 8, both 3 units from the center. Change the distance to 0 and the two answers merge into 5. Change it to -3 and the calculator reports no solution, because nothing sits a negative distance away from anything.

One last habit: leave the boxes empty rather than typing 0 when you have no value. The calculator treats a blank as 0 instead of showing an error, so you can fill in what you know and read the rest later.

Frequently asked questions

What is the absolute value of -7.5?

It is 7.5. The bars measure the distance from 0, so a negative number and its opposite share the same absolute value, and |-7.5| = |7.5| = 7.5.

Why is the absolute value of a number always positive?

Because it is a distance, and a distance cannot be less than zero. The only exception in wording is that 0 has an absolute value of 0, since the distance from 0 to 0 is 0.

What is the distance between 18 and 45 on a number line?

It is 27, written |18 - 45| = 27. The order of the two numbers does not change the distance, and the halfway point between them is 31.5.

How do you solve |x - 5| = 3?

With two answers: x = 2 and x = 8. The number has to sit exactly 3 units from the center 5, and there are two spots that far away, one on each side.

How many solutions does |x - c| = d have?

Two when d is above 0, since the answers are c - d and c + d. One when d is 0, because both answers land on c. None when d is negative, since a distance cannot be negative.

What does a tolerance band like |x - 250| <= 2 mean?

It means a measurement passes when it lands from 248 to 252. A reading of 249.2 is 1.2 from the target and passes, while 253.6 is 3.6 away and fails. The sign of the miss never changes the result.

What is the difference between absolute error and relative error?

Absolute error is the size of the miss in your own units, for example |12.4 - 12| = 0.4 inches. Relative error divides that by the true value, so the same 0.4 inches on a 12 inch part is 3.33%.

Why do people avoid relative error when the true value is near zero?

Because dividing by a tiny number inflates the result. A miss of 0.001 on a true value of 0.01 is 10% relative error even though the absolute error is only 0.001, so near zero the absolute number says more.

What is ABS in Excel?

It is the spreadsheet version of absolute value. Typing =ABS(A1) returns 7.5 for a cell holding -7.5, and =ABS(-7.5) does the same thing with the number typed in.

What is abs() in Python and Math.abs() in JavaScript?

They are the built in absolute value functions. abs(-7.5) in Python and Math.abs(-7.5) in JavaScript both return 7.5, which is useful when a script has to compare a result against a limit.

Can an absolute value be negative?

No. The result of an absolute value is 0 or more, always, because it measures a distance. An equation like |x - 5| = -3 has no solution for the same reason.

Is absolute value the same as absolute change?

They are related but different. Absolute value measures the size of a number, while absolute change measures the size of a difference between two readings, usually with a percentage attached. This page stays on the number, the distance between two points, and the two solutions of an equation.

What is the midpoint between two numbers?

It is the average of the two, and it is the point with equal distance to each. For 18 and 45 the midpoint is 31.5, and every point within 13.5 of it is closer to one end than to the other.

How do I use absolute value for a temperature check?

Compare the reading with the setpoint and take the distance between them. A thermostat set at 68 degrees with a reading of 64.5 gives |64.5 - 68| = 3.5 degrees of deviation, whether the room is cold or warm.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.