Absolute Difference Calculator
Calculate the absolute difference between two numbers. Find |A − B| with calculation steps, midpoint, signed difference, and percentage comparison.
Updated
What is the Absolute Difference Calculator?
Calculate the absolute difference between two numbers instantly. Enter any two positive, negative, or decimal values to find how far apart they are.
Absolute difference = |A − B|
What is absolute difference?
Absolute difference is the distance between two numbers, regardless of direction. It is always zero or positive — never negative.
For example:
|3 − 9| = |−6| = 6
So 3 and 9 are 6 units apart.
Absolute difference formula
∣A−B∣={A−BB−Aif A≥Bif A<B
In words: subtract the two numbers, then drop the sign.
Absolute difference vs. signed difference
| Calculation | Example (A = 3, B = 9) | Result | Meaning |
|---|---|---|---|
| Signed difference (A − B) | 3 − 9 | −6 | Direction included: A is 6 less than B |
| Absolute difference ( | A − B | ) |
Signed difference preserves direction (which value is larger). Absolute difference represents only the magnitude — the distance.
Absolute difference vs. percentage difference
- Absolute difference tells you how far apart two values are (e.g. 20).
- Percentage difference tells you how large that gap is relative to their size (e.g. 22.22% of the average).
- Percentage change is directional: it measures growth or decline from one value to another, and changes depending on which value you start from.
Use absolute difference when you care about the gap itself. Use a percentage when you need to compare gaps across different scales.
When to use absolute difference
- Comparing two measurements or test results
- Checking how far a value is from a target or tolerance
- Finding the spread between prices, scores, or dates-as-numbers
- Understanding the distance between any two points on a number line
How it works
How the calculation works
- Enter two numbers, A and B.
- The calculator finds the signed difference: A − B.
- It takes the absolute value to get the distance: |A − B|.
- It also shows the midpoint (A + B) / 2 and the percentage relationships below.
The result updates as you type. Use Swap to reverse A and B, Reset to clear, and Copy Results to export.
Formulas used
| Metric | Formula | When shown |
|---|---|---|
| Absolute difference | A − B | |
| Signed difference | A − B | Always |
| Midpoint | (A + B) / 2 | Always |
| Percent of A | A − B | |
| Percent of B | A − B | |
| Percent of average | A − B |
A percentage shows as — when its denominator is zero, because division by zero is undefined.
Percentage difference, percentage change, and percent of average
- Percent of A and Percent of B are directional: they answer "how big is the gap compared to A (or B)?"
- Percent of average is symmetric: swapping A and B gives the same result. For positive numbers it equals the standard percentage-difference formula.
- Percentage change is different: it measures growth from an old value to a new value, ((new − old) / |old|) × 100%, and its sign matters. For growth and decline, use a percentage-change calculator instead.
When A and B have opposite signs, the midpoint can be small or zero, which makes percent of average very large or undefined (for example, −50 and 50 have midpoint 0). In that cross-zero case, rely on percent of A or percent of B.
Supported inputs
The calculator supports whole numbers, decimals, negative numbers, zero, scientific notation (for example 1.5e10), and comma-separated thousands (for example 1,000,000).
Precision
Calculations use standard browser floating-point arithmetic, so extremely large or highly precise values may be subject to floating-point rounding.
Privacy
Your calculations run in your browser. The values you enter are not sent to a server.
Examples
Basic numbers: 50 and 30
Find how far apart two simple numbers are.
Value A: 50, Value B: 30|50 − 30| = |20| = 20. Signed difference: 20, Midpoint: 40Negative numbers: -15 and 25
Distance across zero on the number line.
Value A: -15, Value B: 25|−15 − 25| = |−40| = 40. Signed difference: -40, Midpoint: 5Decimals: 3.14 and 2.71
Compare decimal values precisely.
Value A: 3.14, Value B: 2.71|3.14 − 2.71| = |0.43| = 0.43. Midpoint: 2.925Equal values: 25 and 25
Identical values have zero distance.
Value A: 25, Value B: 25|25 − 25| = |0| = 0. Values are equal, Midpoint: 25One value is zero: 0 and 10
Distance from zero is the other value's magnitude.
Value A: 0, Value B: 10|0 − 10| = |−10| = 10. Percent of A: — (undefined), Percent of B: 100%Frequently asked questions
What is absolute difference?
What is absolute difference?
Absolute difference is the distance between two numbers, calculated as |A − B|. It tells you how far apart the values are, ignoring direction. For example, |3 − 9| = 6.
How do you calculate absolute difference?
How do you calculate absolute difference?
Subtract the two numbers, then take the absolute value: |A − B|. For 50 and 30: |50 − 30| = |20| = 20. The calculator above shows each step automatically.
What is the difference between absolute difference and subtraction?
What is the difference between absolute difference and subtraction?
Subtraction (A − B) keeps the sign, so it tells you both the size and the direction — for example, 3 − 9 = −6 means A is smaller. Absolute difference (|A − B|) drops the sign and gives only the distance — |3 − 9| = 6.
Can absolute difference be negative?
Can absolute difference be negative?
No. Absolute difference is always zero or positive. If both values are equal, it is 0; otherwise it is greater than 0.
Does the order of the numbers matter?
Does the order of the numbers matter?
No for absolute difference: |A − B| = |B − A|, so swapping gives the same result. Order does matter for signed difference (A − B flips sign) and for percent of A versus percent of B.
How do you find the absolute difference between negative numbers?
How do you find the absolute difference between negative numbers?
Use the same formula. For −15 and −25: |−15 − (−25)| = |10| = 10. For mixed signs like −15 and 25: |−15 − 25| = |−40| = 40, the full distance across zero.
What is the difference between absolute difference and percentage difference?
What is the difference between absolute difference and percentage difference?
Absolute difference is the raw gap (|A − B|, e.g. 20). Percentage difference expresses that gap relative to size — this calculator's "Percent of average" is |A − B| / |(A + B) / 2| × 100%, which matches the standard percentage-difference formula for positive numbers. Percentage change is directional and measures growth from one value to another.
What happens if one value is zero?
What happens if one value is zero?
The absolute difference is simply the magnitude of the other value: |0 − 10| = 10. Percentages relative to the zero value are undefined and shown as —, because division by zero is not possible.
Can I calculate the absolute difference between decimals?
Can I calculate the absolute difference between decimals?
Yes. For example, |3.14 − 2.71| = |0.43| = 0.43. Enter decimals, negative numbers, scientific notation (like 1.5e10), or comma-separated thousands (like 1,000,000).
How is the result calculated?
How is the result calculated?
The calculator computes |A − B| for the absolute difference, A − B for the signed difference, (A + B) / 2 for the midpoint, and |A − B| divided by |A|, |B|, or the midpoint magnitude for the three percentages. The "Calculation steps" box above shows the exact substitution for your inputs.
Related tools
More utilities you might find handy.
Age Calculator
Calculate your exact age in years, months and days from your date of birth.
Aspect Ratio Calculator
Enter any width and height to find the simplified aspect ratio, solve a missing dimension, and preview the shape — for images, video, screens and print.
Average Calculator
Calculate the arithmetic mean of any set of numbers instantly. Enter values separated by commas, spaces, or line breaks.