Absolute Difference Calculator

Absolute Difference Calculator

Emerging AI Skill PRO

Enter Calculation

Formula

|Value A−Value B|\left| \text{Value A} - \text{Value B} \right|
Usage stats

Advertisement

Results

Absolute Difference
7
| A − B |
Value A 12
Value B 5
Signed difference (A − B) 7

Report an error on this page

What Is the Absolute Difference?

The absolute difference between two numbers is the distance between them on the number line, always expressed as a non-negative value. Written mathematically as \(|a - b|\), it ignores which number is larger and simply tells you how far apart the two values are. Because the result of a subtraction can be negative, the absolute value bars strip away the sign so the answer is never below zero.

Number line showing two points a and b with the distance between them marked
The absolute difference is the distance between a and b on the number line.

How to Use This Calculator

Enter your first number in the Value A field and your second number in the Value B field. The calculator subtracts B from A and returns the absolute value of that result. It also shows the signed difference (A − B) so you can see the direction of the gap if that matters for your problem. Both whole numbers and decimals, positive or negative, are accepted.

The Formula Explained

The formula is simply $$d = |a - b|$$ First compute \(a - b\). If the result is negative, drop the minus sign; if it is positive or zero, leave it as is. For example, both \(10 - 3 = 7\) and \(3 - 10 = -7\) give an absolute difference of 7, because \(|7| = |-7| = 7\). The absolute difference is symmetric: \(|a - b| = |b - a|\).

Advertisement
Diagram showing that the order of subtraction does not change the absolute difference
Whether you compute a minus b or b minus a, the absolute value gives the same non-negative result.

Worked Example

Suppose Value A = 12 and Value B = 5. The signed difference is \(12 - 5 = 7\). Since 7 is already positive, the absolute difference is \(|7| = 7\). Now reverse them: A = 5, B = 12 gives \(5 - 12 = -7\), and \(|-7| = 7\) — the same answer.

FAQ

Can the absolute difference be negative? No. By definition it is always zero or positive.

What if both numbers are equal? The absolute difference is 0, since \(|a - a| = 0\).

Does the order of A and B matter? Not for the absolute difference — \(|a - b|\) equals \(|b - a|\). It only changes the sign of the displayed signed difference.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators