Absolute Value Calculator
Result
Absolute value
- Opposite
- -7.000000
An absolute value calculator strips the sign off a number: the absolute value of −9 is 9, and so is the absolute value of 9. This page prints a second number beside it — the opposite, which is what you get by flipping the sign rather than by removing it — because the two are taught together and readers reasonably want to see how they differ. For a positive number they differ; for a negative number they land on the same answer, and that coincidence is the single most useful thing on the page. Enter any number, positive, negative or fractional, and both readings come back at once.
Distances on the number line
| a | b | Distance |
|---|---|---|
| -3 | 2 | 5 |
| -5 | -1 | 4 |
| 0 | 7 | 7 |
| -4 | 4 | 8 |
| -10 | -2 | 8 |
| 3 | -6 | 9 |
| -1 | 1 | 2 |
| 12 | 5 | 7 |
| -8 | -8 | 0 |
Each row is the absolute value of a subtraction: the distance between a and b is |a − b|, which strips the sign the subtraction produced and leaves the length of the gap. The row for a and b both equal to −8 returns 0, the case where the two points coincide; the row from −4 to 4 returns 8, twice the distance from either point to zero. The numbers are whole on purpose — a table of decimal distances would need localizing, since 1,5 is written that way in several languages and 1.5 in others, while whole numbers are written identically everywhere. Note that this table shows a calculation the calculator above cannot do: it takes one number, not two.
Formula
|x| = x (x ≥ 0) |x| = −x (x < 0) opposite = −x
- x
- The number you enter. Any real number is accepted within the page's range: positive, negative, zero, whole or fractional. Nothing about the input is restricted, because the absolute value is defined for every real number — it is the one operation on this site with no domain to state.
- |x|
- The absolute value, the primary reading: the distance from zero to the number on the number line, which is never negative. Written as two rules rather than one, because the rule changes at zero — for a non-negative number you simply drop nothing, and for a negative number you take its negation, which is what makes the result positive.
- −x
- The opposite, the number on the other side of zero at the same distance. It is not the same instruction as the absolute value: the opposite of 7 is −7 while the absolute value of 7 is 7, and the two only agree when the input is zero or negative. Reading the sign off the second column is not a bug in the calculator; it is the definition of the operation applied to a negative number.
Worked examples
The absolute value of a positive number
- 7 is not negative, so the first rule applies: |7| = 7
- The absolute value is 7, unchanged
- The opposite is −7, the same distance on the other side of zero
- The two readings differ, which is the usual case for a positive input
The case the page opens on, and the clearest way to see that the two columns are answering different questions. Removing a sign and flipping a sign happen to look similar on paper, but on a positive number they give different answers, and no reader who has seen this row will confuse them again.
The absolute value of a negative number
- −9 is negative, so the second rule applies: |−9| = −(−9)
- That is 9, the distance from zero to −9
- The opposite of −9 is also 9
- Both columns print 9 — the same number twice, and not an error
The row that most often gets reported as a bug. When the input is negative, the two operations coincide, because removing the sign and flipping the sign lead to the same place: −x is exactly what the absolute value is for a negative x. That the columns agree is information, not a duplicated calculation — it says the input was negative.
The absolute value of a number between 1 and −1
- 0.125 is positive, so the absolute value is 0.125
- The opposite is −0.125
- Both numbers are smaller than 1, which does not change either rule
- The absolute value is still the distance from zero
Fractions behave exactly like whole numbers here — the rules are about the sign and nothing else, so size never enters into it. A number between 0 and 1 has a small absolute value and an equally small opposite, and the pair still sits symmetrically around zero on the number line.
Limitations
The page takes one number and returns its absolute value and its opposite. It does not compute the distance between two points, even though that distance is written with absolute value bars — the length of the gap between a and b is |a − b|, which needs two numbers to start with, and the general distance calculator linked from this page takes both coordinates. When the input is negative the two columns print the same number, and that is a consequence of the definition rather than a rounding artefact: for a negative x, the absolute value and the opposite are the same expression, −x. Zero is the only number equal to its own opposite, and its absolute value is zero as well. Inputs are limited to fifteen digits of magnitude, beyond which the page would have to fall back on scientific notation instead of printing the number plainly. The result is rounded to six decimals for display while the arithmetic behind it runs at full precision. There is no classification badge on this page, because whether the input was positive, negative or zero is already visible in the two numbers themselves.
Frequently asked questions
- What is the absolute value of a number?
- It is the distance from that number to zero on the number line, which is why it is never negative. The absolute value of −9 is 9 and the absolute value of 9 is also 9: both numbers sit nine units from zero, just on opposite sides. The two bars around the number are the notation for that distance, not a bracket or a parenthesis.
- Why does the calculator print the same number twice for a negative input?
- Because for a negative number the absolute value and the opposite are the same expression. The definition says |x| = −x when x is negative, and the opposite is −x by definition, so the two columns must agree. −9 has an opposite of 9 and an absolute value of 9. Far from being a duplicated calculation, the agreement tells you something: it tells you the input was negative or zero.
- What is the difference between the absolute value and the opposite?
- The absolute value removes the sign; the opposite flips it. On a positive number those are different instructions — the absolute value of 7 is 7 and its opposite is −7. On a negative number they lead to the same place, and on zero they both give zero. The page shows both columns so that the distinction is visible rather than something a reader has to take on trust.
- Can the absolute value ever be negative?
- No. It is a distance, and distances are not negative. This holds for every real number, including very large negative ones: the absolute value of −1000000 is 1000000. If a calculation produces a negative absolute value, one of the steps has misapplied the definition — most often by negating a number that was already positive.
- Does the absolute value of zero have a sign?
- It is zero, and zero is the only number that is its own opposite. In JavaScript arithmetic, negating zero can produce a negative zero, which prints as 0 but compares as different from 0 under strict identity checks. The page normalizes both columns so that an input of zero gives a plain zero in each, with no stray minus sign hiding in the value.
- Does this page find the distance between two points?
- No. It takes one number, and the distance between two points needs two — the gap between a and b is |a − b|. The reference table below shows that calculation worked out on the number line, and the distance calculator linked at the bottom of the page handles it in the plane, where the answer involves the square root of the sum of two squares rather than a single subtraction.
References
- Absolute Value — the two-case definition, the number-line reading as distance from zero, and the notation — Wolfram MathWorld (United States)
- Additive Inverse — the opposite of a number, the operation behind the page's second column — Wolfram MathWorld (United States)
- Real Line — the axis whose every point is a real number: the picture the absolute value is a distance on, and where the opposite sits — Wolfram MathWorld (United States)