Absolute Value Calculator

Enter a real number x. The calculator returns |x|: distance from zero on the line. For −7 the result is 7; for 12.5 it is 12.5; for 0 it is 0. Definition: x when x ≥ 0, otherwise −x. This is not the complex modulus √(a²+b²) and not signum.

Input

Result

Enter a number.

One field, one result. Signum lives on sign of a number (signum). Vector length — on vector length.

How it works

How |x| is computed for x = −7
x−7
branchx < 0 → −x
|x|7

The absolute value of a real number x, written |x|, is the distance of the point x from zero on the number line. Piecewise definition: |x| = x when x ≥ 0; |x| = −x when x < 0. The calculator uses the number you enter in the “Number” field and computes |x| — the same result as the classical definition.

For real numbers one also has |x| = √(x²). Squaring removes the sign, and the principal square root returns the non-negative magnitude. For x = −7: (−7)² = 49, √49 = 7, so |−7| = 7. For x = 12.5 the result stays 12.5. For x = 0 the result is 0. Mathematical model: absolute value (modulus) on ℝ — the metric d(0, x) = |x|.

The result is always non-negative: domain ℝ, range [0, ∞). Signum returns only the sign (1, −1, or 0); vector length builds √(a²+b²) from several coordinates. An empty field leaves the result blank. A period and a comma are equivalent.

The triangle inequality |a+b| ≤ |a|+|b| and the identity |x| = x·sgn(x) (for x ≠ 0) belong to the theory around the same function. The panel shows √(x²), x², −x, sgn(x), and which branch of the definition applies. The number line marks the segment from zero to x of length |x|.

Worked examples: |−7| = 7; |12.5| = 12.5; |0| = 0; |−3.2| = 3.2; |100| = 100; |−0.5| = 0.5; |7| = 7; |−12| = 12. This is not a 0–100 scale or a made-up index — only the distance from zero of one real number.

Formula

|x| = x when x ≥ 0; otherwise |x| = −x.

Equivalently for reals: |x| = √(x²). Distance from zero: d(0, x) = |x|.

Computation: |x|. Model: absolute value (modulus) on ℝ.

Theory, metric, and derivation

Definition

The absolute value (modulus) of a real number x is the function |·| : ℝ → [0, ∞) given piecewise by |x| = x when x ≥ 0, and |x| = −x when x < 0. Equivalently |x| = √(x²) with the principal (non-negative) square root. Geometrically |x| is the distance of the point x from zero on the number line, that is d(0, x) in the Euclidean metric on ℝ. The calculator implements |x| in the browser’s floating-point arithmetic — the result should match this definition for finite inputs.

The notation |x| with vertical bars is standard in analysis and in schoolwork. The same symbol is sometimes used for set cardinality or for a determinant; meaning follows from context. Here it means only the modulus of a single real variable. The definition appears in Rudin (Principles of Mathematical Analysis), in school algebra texts, and in MathWorld (Absolute Value) and NIST elementary-function notes.

In teaching practice it helps to separate the mathematical formula from floating-point limits: this calculator shows the browser’s floating-point computation (about 15–16 significant digits), not a paper proof of symbolic identities. When inputs are extreme, check the domain first, then the floating-point range.

Historical and conceptual context

The idea of “magnitude without sign” is older than the modern |x| notation. In Greek geometry a segment length was non-negative by definition; algebra with negative numbers needed an explicit “drop the sign” rule. The modern piecewise definition and the link to √(x²) are part of the standard real-analysis curriculum of the nineteenth and twentieth centuries. In metric topology |x − y| is the canonical distance on the line; in functional analysis the generalization is a norm ‖·‖, and on the complex plane the modulus |a + bi| = √(a² + b²).

Conceptually, absolute value does not sort lists, compute percentiles, or solve equations such as |x − 2| = 5 — those tasks need branch analysis or a separate solver. This calculator answers one question: what is the distance of the entered number from zero. Signum, floor, fractional part, and vector length live on neighboring pages because they answer different questions about the same number or about several coordinates.

In engineering and statistics |x| appears in absolute errors, deviations from a target, and in denominators (for example |old| in percentage change) where direction should stay in the numerator, not in the division base.

Formal properties

Domain: x ∈ ℝ. Range: [0, ∞). |x| = 0 if and only if x = 0. Evenness: |−x| = |x|. Positive homogeneity: |λx| = |λ|·|x| for λ ∈ ℝ. Triangle inequality: |x + y| ≤ |x| + |y|. Reverse triangle inequality: ||x| − |y|| ≤ |x − y|. Multiplicativity: |xy| = |x|·|y|. For x ≠ 0: |x| = x · sgn(x) and sgn(x) = x / |x|.

Links to max and min: max(a, b) = (a + b + |a − b|)/2 and min(a, b) = (a + b − |a − b|)/2. Hence, max − min = |a − b|. On the line |x| is distance from zero; |a − b| is distance between a and b. The function f(x) = |x| is convex, continuous everywhere, and differentiable away from zero (derivative sgn(x) for x ≠ 0).

The identity √(x²) follows because x² ≥ 0 and the principal square root is non-negative: for x ≥ 0 one has √(x²) = x; for x < 0 one has √(x²) = −x.

Full derivation

Step 1. Let x ≥ 0. The piecewise definition gives |x| = x. Also, x² = x·x and √(x²) = x because x is non-negative. Hence, |x| = √(x²).

Step 2. Let x < 0. The definition gives |x| = −x (a positive number). The square x² = (−x)·(−x) = (−x)², so √(x²) = −x. Thus, again |x| = √(x²).

Step 3. When x = 0 both branches give 0. |0| = 0. The distance from zero is zero.

Step 4. The calculator computes |x|. The √(x·x) check in the panel should match |x| in floating-point arithmetic up to square-root representation. For typical school data (for example −7, 12.5) both paths give the same displayed result after formatting.

Step 5 (metric). The function d(x, y) = |x − y| satisfies the metric axioms on ℝ: non-negativity, identity of indiscernibles, symmetry, and the triangle inequality. The case y = 0 reduces to |x|.

Special cases

Examples: |−7| = 7; |7| = 7; |12.5| = 12.5; |0| = 0; |−3.2| = 3.2; |100| = 100; |−0.5| = 0.5; |−12| = 12. The sum |−7| + |7| is 14, not 0 — you drop signs first, then add. The raw sum −7 + 7 would be zero, but that is a different operation.

An undefined value (NaN) passes through |x| unchanged; this calculator requires a finite input and shows an error on unparsable text. ±Infinity: |±∞| = +∞ in computer arithmetic, but the form expects finite values.

Negative zero (−0): |−0| = 0 in computer arithmetic (result +0). The calculator does not show a separate “negative zero” label in the result — the distance is still 0.

Numerical notes

The comparison x ≥ 0 is exact for finite numbers other than NaN. The product x·x can overflow to Infinity for huge |x|, while |x| still returns a finite magnitude up to the floating-point arithmetic limit — so the built-in absolute value is safer than √(x²) at extremes; the panel still shows both paths on typical data.

A period and a comma are equivalent in the parser. The axis diagram marks zero, the point x, and the segment of length |x|. The unit setting do not change the mathematical result.

Display rounding (locale en-US / pl-PL) does not change the internal value: |−7| is exactly 7, not “about 7.”

Related notions and sources

Related: sign of a number (signum), square root (because |x| = √(x²)), maximum of two numbers (identity with |a−b|), vector length, percentage change with |old|, fractional part and floor. Complex modulus is a separate geometric model on the plane.

Sources: Wikipedia — Absolute value; MathWorld — Absolute Value; Rudin, W., Principles of Mathematical Analysis; ProofWiki — definitions and the triangle inequality. Educational tool — not a textbook substitute or a teacher’s check.

How to use

  1. Enter a number in the Number field (for example −7).
  2. Click Calculate or wait for the live result. |−7| = 7. |12.5| = 12.5.
  3. Check the panel: √(x²), x², −x, sgn(x), definition branch, and the axis segment from zero.
  4. At zero the result is 0. For a positive number the result equals the input.
  5. Signum and vector length live on neighboring pages — here only |x| of one number.

Symbol glossary

|x| = distance from zero. For −7 the result is 7. The panel also shows √(x²) and sgn(x).

|x|
Absolute value: x when x ≥ 0, otherwise −x. Always ≥ 0.
x
Real number from the wartosc-bezwzgledna-a field.
√(x²)
Equivalent form on ℝ. Check in the result panel.
sgn
Sign: 1, −1, or 0. For x ≠ 0: |x| = x · sgn(x).
d(0,x)
Euclidean metric on the line: distance from zero equals |x|.

Examples

Example 1

  • Number: −7

7

What is |−7|? 7.

Example 2

  • Number: 12.5

12.5

What is |12.5|? 12.5.

Example 3

  • Number: 0

0

What is |0|? 0.

Example 4

  • Number: −3.2

3.2

What is |−3.2|? 3.2.

Example 5

  • Number: 100

100

What is |100|? 100.

Example 6

  • Number: −0.5

0.5

What is |−0.5|? 0.5.

Example 7

  • Number: 7

7

What is |7|? 7 (same magnitude as |−7|).

Example 8

  • Number: −12

12

What is |−12|? 12.

Related calculators

Frequently asked questions

What does this calculator compute?

It returns the absolute value of one real number x, that is |x|. For x = −7 the result is 7; for x = 12.5 it is 12.5; for x = 0 it is 0. That is distance from zero on the line — not signum and not vector length from several coordinates.

What is the piecewise definition of |x|?

If x ≥ 0, then |x| = x; if x < 0, then |x| = −x. When x = 0 both branches give 0. Vertical bars |x| are the school and textbook notation; square brackets mean an interval, not absolute value.

Why is |x| = √(x²) for real numbers?

The square x² is always non-negative, and the principal square root returns the non-negative root of that value. For x ≥ 0: √(x²) = x. For x < 0: √(x²) = −x. The result panel shows √(x²) beside the primary |x| so both paths match in browser arithmetic.

How does |x| differ from signum (sgn)?

Absolute value keeps the magnitude and drops the sign: |−7| = 7. Signum keeps the sign and drops the magnitude: sgn(−7) = −1. For x ≠ 0 one has |x| = x · sgn(x). Signum lives on the separate sign-of-a-number page.

Can the result be negative?

No. By definition |x| ≥ 0 for every real x. The smallest possible result is 0, when x = 0. A minus in the input only says which side of zero you stand on, not the sign of the result.

What is the triangle inequality for absolute value?

For any real a and b: |a + b| ≤ |a| + |b|. That is a basic property of the metric d(x, y) = |x − y| on ℝ. This calculator computes one value |x|, not a sum of two independent moduli — the inequality belongs to the theory, not to a separate form field.

How is this different from vector length and complex modulus?

Here one field: distance |x| on the real line. Vector length (a, b) is √(a² + b²) on another page. The modulus of a complex number a + bi is also √(a² + b²); this calculator does not take an imaginary part.

What happens with an empty field?

An empty Number field leaves the result blank. The calculator does not substitute zero for a missing entry. Zero must be entered on purpose — then |0| = 0.

Do a comma and a period work the same way?

Yes. 12.5 and 12,5 are the same number. Enter a leading minus when needed. Example: |−3.2| = 3.2.

Do the currency and unit settings in the page header affect the result?

No. The result depends only on the number x. The currency and unit settings in the page header do not affect this result.

How do −0 and 0 behave in the browser?

Floating-point arithmetic has a signed zero, but |−0| yields +0, and the distance from zero is still 0. This calculator treats zero from the field as result 0 — with no separate branch for −0.

Where do I compute percentage change with |old| in the denominator?

On the percentage-change page. There the denominator uses |old| so the percent sign speaks about direction. Here you compute |x| of a single number.

How do I calculate absolute value?

If x ≥ 0, |x| = x; if x < 0, |x| = −x. For −7 the result is 7; for 12.5 it is 12.5. On ℝ also |x| = √(x²).

What is |−7|?

7. That is the first example on this page: the x < 0 branch gives |x| = −x = 7.

What is |−3.14|?

3.14. The minus drops; the magnitude stays. Same rule as |−3.2| = 3.2 on this page.

Does this compute |a − b| or solve |x| = k?

No. Here one field: |x| for a single real number. Distance |a − b| and absolute-value equations are not separate form modes.

Does it accept complex numbers?

No. The modulus of a + bi is √(a² + b²) — a separate tool. Here only distance on the real line.

The result is |x|: for −7 it is 7. The √(x²) check returns the same. Signum is on sign of a number.

Sources

The definition, √(x²), triangle inequality, and metric below come from recognized sources.

Page updated November 3, 2026.