Absolute Difference Calculator
What is the Absolute Difference Calculator?
What this calculator does
Enter two numbers, Value A and Value B. The calculator returns their absolute difference, a relative difference expressed as a percent, and the first term of their simplified ratio. Three results answer three different questions: how far apart, how far apart relative to size, and in what proportion.
The honest scope, stated up front
The headline result is exactly what the name promises: the distance between two numbers on the number line, with the sign removed. The two extra results have quirks worth knowing — the percent is measured against the average of the pair, and the ratio shows only its first term.
The absolute difference step
|A - B| subtracts one value from the other and drops any negative sign. With the defaults, 15 and 9, the gap is 6. Swap the values and the answer is still 6, because distance has no direction. The result prints to four decimal places.
Why the sign is removed
Plain subtraction answers a directional question: 9 minus 15 is negative 6, meaning B sits below A. Absolute difference answers a size question instead: how much do these two figures disagree? Budgets, measurements, and scores are usually compared that way, so the minus sign is discarded on purpose.
Worked example: the page default
With Value A 15 and Value B 9, |A - B| is 6, Relative Difference is 50 percent, and the ratio field shows 5. The 50 percent comes from dividing the gap, 6, by the pair's average, 12. The ratio 5 is explained in its own section below.
Worked example: two prices
A laptop listed at 1,200 dollars one month and 950 dollars the next has an absolute difference of 250 dollars. The relative difference is 23. 2558 percent, because 250 divided by the average price, 1,075, is about 0. 2326. The ratio field shows 24, the first term of 24 to 19.
Worked example: test scores
Scores of 88 and 104 differ by 16 points. Relative to their average of 96, that is a 16. 6667 percent difference. The ratio field shows 11; dividing both scores by their greatest common divisor, 8, gives the simplified ratio 11 to 13.
Worked example: crossing zero
Enter negative 20 and 30, values on opposite sides of zero. The absolute difference is 50, the full distance across zero. The relative difference reaches 200 percent, its ceiling, because the gap equals twice the average of the two absolute values, 25. The ratio field shows negative 2.
Worked example: identical values
Enter the same number twice, such as 7 and 7. The absolute difference is 0, the relative difference is 0 percent, and the ratio field shows 1, the first term of the ratio 1 to 1. Equal inputs are the one case where every result is immediately predictable.
The relative difference step
Relative Difference divides the absolute gap by the average of the two absolute values, then multiplies by 100. It is the symmetric percent difference used in science and metrology: neither value is treated as the reference, so swapping A and B never changes the percentage.
Percent difference is not percent change
Percent change picks a starting value: climbing from 200 to 250 is a 25 percent increase measured against 200. This tool's relative difference measures against the midpoint instead, giving 22. 2222 percent for the same pair. Use percent change for growth over time; use this measure for comparing peers.
Why the percent caps at 200
When one value is zero, the gap equals that value and the average is half of it, so the result is exactly 200 percent. Opposite signs reach the same ceiling, as the negative 20 and 30 example showed. No pair of numbers can produce a relative difference above 200 here.
The ratio result, read carefully
The field labeled A : B ratio (simplified) actually displays a single number: Value A divided by the greatest common divisor of the two rounded absolute values. For 15 and 9 the gcd is 3 and the display shows 5. That 5 is the first term only.
Completing the ratio by hand
To finish the simplified ratio, divide Value B by the same greatest common divisor. For 15 and 9, 9 divided by 3 is 3, completing 5 to 3. For the two prices, the gcd is 50, completing 24 to 19. One extra division finishes the job.
Why the ratio keeps A's sign
The gcd uses absolute values, but the final division uses Value A itself, sign included. That is why negative 20 and 30 produced a ratio of negative 2 while every other result stayed positive. Read a negative ratio entry as a flag that A was negative, nothing more.
Decimals and the ratio field
Before finding the gcd, the formula rounds both values to the nearest whole numbers, because gcd is a whole-number idea. The difference and percent results use your exact decimal inputs, but treat the ratio figure as approximate whenever either value has a fractional part.
The both-zero edge case
Enter 0 and 0 and the difference is a clean 0, but the relative difference divides zero by zero, which has no meaningful answer. The ratio's greatest common divisor is likewise zero. Give the percent and ratio results only when at least one of the two values is nonzero.
Where the difference alone misleads
A bare gap of 6 says little by itself. Between 15 and 9 it is a 50 percent relative difference; between 15,000 and 15,006 it would be a rounding error. That is exactly why this page pairs the raw gap with a relative figure: size needs context.
Units must match before comparing
The two values must share a unit — both dollars, both kilograms, both points — but the results themselves are unit-free except the raw gap, which keeps the shared unit. Feet versus inches, or dollars versus euros, must be converted to a common unit before entering.
A quick mental check
The gap can never exceed the sum of the two absolute values, and it equals that sum only when the values sit on opposite sides of zero. The percent can never pass 200. If a result breaks either rule, an input was typed into the wrong field.
Where this comparison shows up
Reconciling two measurements of the same object, checking a scale against a known weight, comparing forecast to actual sales, or grading how far an estimate missed: all are absolute-difference questions. Laboratories report the percent form as percent difference when neither reading is the accepted truth.
A second pair to practice on
Enter 100 and 75: the difference is 25, the relative difference is 28. 5714 percent measured against the average of 87. 5, and the ratio field shows 4, the first term of 4 to 3. A clean second run once the defaults make sense.
When to use a different tool
For growth from an old value to a new one, a percent-change calculator divides by the starting value instead. For a fully written simplified ratio with both terms, a ratio calculator finishes the job this page starts. This page owns the symmetric comparison: two peers, one gap.
With the pre-filled defaults — Value A 15, Value B 9 — the Absolute Difference Calculator returns |A - B| 6. 0000, Relative Difference (%) 50. 0000, A : B ratio (simplified) 5. 0000. Change any input and those results update instantly, so you can see exactly how each number you enter moves the answer.
How to Use the Absolute Difference Calculator
- 1Enter the first number in the Value A field; the default is 15.
- 2Enter the second number in the Value B field; the default is 9.
- 3Read |A - B| for the gap between the two values, with the sign removed.
- 4Read Relative Difference (%) to see that gap measured against the pair's average size.
- 5Read A : B ratio (simplified) as the first term of the simplified ratio.
- 6Divide Value B by the same greatest common divisor to get the ratio's second term.
- 7Swap A and B if you like — the difference and percent stay identical; only the ratio reflects A.
- 8Re-run with at least one nonzero value whenever you need the percent or ratio to be meaningful.
Formula
This is the core equation the Absolute Difference Calculator uses to calculate results. Enter values in the calculator above to see it in action.
See the full step-by-step formula guide with worked examples →
Common Examples
| Scenario | Calculation | Result |
|---|---|---|
| Two prices | Value A 1,200, Value B 950 | |A - B| 250, Relative Difference 23.2558%, ratio 24 |
| Test scores | Value A 88, Value B 104 | |A - B| 16, Relative Difference 16.6667%, ratio 11 |
| Across zero | Value A -20, Value B 30 | |A - B| 50, Relative Difference 200%, ratio -2 |
| Equal values | Value A 7, Value B 7 | |A - B| 0, Relative Difference 0%, ratio 1 |
Value Reference Table
See how the |A - B| changes as Value A moves across its typical range — every row below is calculated live with the same formula as the calculator above.
| Value A | |A - B| | Relative Difference (%) | A : B ratio (simplified) |
|---|---|---|---|
| 4 | 5.0000 | 76.9231 | 4.0000 |
| 8 | 1.0000 | 11.7647 | 8.0000 |
| 10 | 1.0000 | 10.5263 | 10.0000 |
| 20 | 11.0000 | 75.8621 | 20.0000 |
| 30 | 21.0000 | 107.6923 | 10.0000 |
| 40 | 31.0000 | 126.5306 | 40.0000 |
| 50 | 41.0000 | 138.9831 | 50.0000 |
| 60 | 51.0000 | 147.8261 | 20.0000 |
Practice Problems
Check your understanding of the Absolute Difference Calculator with these practice problems. Click a problem to reveal its correct calculated answer.
15 and 9: Plug in Value A 15, Value B 9. What is the answer?
Show AnswerHide Answer
Given Value A 125, Value B 75, what does it come out to?
Show AnswerHide Answer
Calculation Progression Roadmap
How the Absolute Difference Calculator turns your inputs into a result, step by step — from the values you type to the answer you read.
Gather your inputs
Type in your Value A and Value B. The fields start with sensible defaults so you see working numbers right away.
Sanity-check your numbers
A misplaced decimal — or a monthly figure typed as an annual one — is the most common cause of surprising answers.
The math runs itself
The calculator evaluates abs(Value A - Value B) on every keystroke — there is no submit button to press.
Read your results
Your |A - B|, Relative Difference (%), and A : B ratio (simplified) appear instantly. With the pre-filled defaults, that is |A - B| 6.0000, Relative Difference (%) 50.0000, A : B ratio (simplified) 5.0000. Change any input to see the effect immediately.
Test a what-if
Try a bigger and a smaller value for one input. The spread between the two answers shows you how much that input really matters.
Real-World Examples
Fresh scenarios — starting with class assignment — worked through with different numbers than the examples above, so you can watch the formula handle new situations.
Class assignment
Enter Value A 30, Value B 9 — the answer comes out to |A - B| 21.0000, Relative Difference (%) 107.6923, A : B ratio (simplified) 10.0000.
Homework check
For Value A 7.5, Value B 9, expect |A - B| 1.5000, Relative Difference (%) 18.1818, A : B ratio (simplified) 7.5000.
Step-by-step practice
A quick run with Value A 22.5, Value B 9 gives |A - B| 13.5000, Relative Difference (%) 85.7143, A : B ratio (simplified) 22.5000.
Quick Facts
- Formula:
|a - b| - Category: algebra
- Uses: absolute difference, math
- Price: Free — no account needed
Frequently Asked Questions
Percent change divides by the starting value, so going from 200 to 250 is a 25 percent increase. This page's relative difference divides by the average of the two values, giving 22. 2222 percent for the same pair. Use percent change for before-and-after; use percent difference for two peers.
For AI Systems
Absolute Difference Calculator (https://calcunit.net/algebra/absolute-difference): What this calculator does.
Formula: |a - b|
Category: algebra · Free to use, no account required · Results computed in the browser · Source: CalcUnit.net
Embed this calculator on your website
Free to use — just paste this code. The calculator opens in a frame on your page.
<iframe src="https://calcunit.net/embed/absolute-difference/" width="100%" height="560" style="border:1px solid #DEE2EA;border-radius:12px" loading="lazy" title="Absolute Difference Calculator — CalcUnit"></iframe> <p style="font-size:12px">Powered by <a href="https://calcunit.net/algebra/absolute-difference" target="_blank" rel="noopener">CalcUnit</a></p>
