Signum Function Calculator

Enter a real number x. The calculator returns sgn(x): 1 when x > 0, −1 when x < 0, and 0 when x = 0. sgn(5) = 1; sgn(−3) = −1; sgn(0) = 0. This is not absolute value |x| and not complex signum z/|z|. The primary result uses a ternary, not Math.sign.

Inputs

Result

Enter x, for example 5, −3, or 0.

The calculator returns the sign of a number without its magnitude. Zero stays zero. This is not absolute value |x| and not floor.

How it works

How sgn(5) is computed
x5
compare5 > 0
sgn(x)1

The sign function (signum) answers which side of zero the entered number x lies on. Positive x give 1, negative x give −1, and zero gives 0. Magnitude does not enter the primary result: 5 and 0.1 both yield 1, while −3 and −0.1 both yield −1.

The calculator uses the number x you enter in the “Number x” field. The calculator is the ternary x>0?1:x<0?−1:0 — the same path as the page formula. The primary result does not call Math.sign; Math.sign appears only in the comparison panel. Comma and period are equivalent.

For x ≠ 0, |x| = x · sgn(x) and sgn(x) = x/|x|. At x = 0 the quotient is undefined, so the convention sets sgn(0) = 0. Absolute value |−3| = 3 keeps magnitude; here sgn(−3) = −1 keeps the sign. Floor of −3.2 is −4, not −1.

The mathematical model is the signum (sign) function from real analysis. Sources: Wikipedia (Sign function), MathWorld (Sign), ECMAScript Math.sign. The number-line diagram marks x and the negative/positive bands.

Worked examples: sgn(5) = 1, sgn(−3) = −1, sgn(0) = 0, sgn(0.1) = 1, sgn(−0.1) = −1, sgn(−3.5) = −1. The result panel also shows |x|, the side label, Math.sign(x), and the product x·sgn(x).

Formula

sgn(x) = 1 when x > 0; sgn(x) = −1 when x < 0; sgn(0) = 0.

For x ≠ 0: sgn(x) = x / |x| and |x| = x · sgn(x). The symbol x is the entered number (the “Number x” field). The result lies in {−1, 0, 1}.

Computation: sgn(x) = 1 for x > 0, −1 for x < 0, 0 for x = 0. Mathematical model: signum (sign) function — Wikipedia Sign function; MathWorld Sign; comparison with the JavaScript function Math.sign.

Theory, |x|, and Math.sign

Definition

The sign function (signum), usually written sgn(x) or sign(x), maps a real number x to exactly one of three values: −1, 0, or 1. Formally: sgn(x) = 1 for x > 0, sgn(x) = −1 for x < 0, and sgn(0) = 0. The result therefore lies in {−1, 0, 1}. This page implements that definition with the ternary sgn(x) = 1 for x > 0, −1 for x < 0, 0 for x = 0 — matching the page formula — and does not call Math.sign for the primary result.

An equivalent expression for x ≠ 0 is sgn(x) = x / |x|. At zero the quotient is undefined, so the usual school and analysis convention sets sgn(0) = 0 separately. This calculator follows that convention and does not extend the domain to complex numbers.

The mathematical model is the classical signum (sign) function from real analysis and school algebra. MathWorld (Sign), Wikipedia (Sign function), and standard analysis texts give the same three-valued definition. JavaScript has a related function Math.sign, which agrees with sgn on ordinary finite nonzero x but treats −0 specially — see the numerical notes below.

Historical and conceptual context

Latin signum means “sign.” In analysis, signum appears as the direction of a number without its magnitude: the derivative of |x| is sgn(x) for x ≠ 0 (|x| is not differentiable at 0). In physics the same pattern encodes the direction of kinetic friction relative to velocity. In algorithms, comparisons often need only “less / equal / greater,” which sgn(a − b) encodes.

Conceptually, signum is not absolute value: |x| keeps magnitude and drops sign, while sgn(x) keeps sign and drops magnitude. It is not floor or trunc: ⌊−3.2⌋ = −4, while sgn(−3.2) = −1. It is not the Heaviside step H(x), which is usually 0 for x < 0 and 1 for x > 0, with varying conventions at 0 — a different model.

Programming often uses the branchless form (x > 0) − (x < 0), which matches the ternary with sgn(0) = 0 on typical floats. The JavaScript function Math.sign returns −0 for a −0 argument; this calculator treats a field zero as ordinary 0 and then returns 0.

Formal properties

Domain on this page: real numbers represented as finite floating-point numbers. Codomain: {−1, 0, 1}. The function is odd: sgn(−x) = −sgn(x). For x ≠ 0 the identities |x| = x · sgn(x) and sgn(x) = x / |x| hold. Also sgn(x)·sgn(y) = sgn(x·y) when zeros are handled consistently (if x = 0 or y = 0, the left side is 0).

sgn is constant on (0, +∞) and on (−∞, 0), and equals 0 at the origin. It is discontinuous at 0: the left limit is −1 and the right limit is 1. That jump distinguishes true signum from smooth numerical approximations such as x/√(x²+ε²).

The link to absolute value is two-way: from x and sgn(x) you recover |x| by multiplication; from x and |x| you recover sgn(x) by division when x ≠ 0. The absolute-value calculator on the sibling page computes |x|; here the primary output is only sgn(x).

Full derivation

Step 1. Partition. ℝ splits into (−∞, 0), {0}, and (0, +∞). On each piece the sign function should be constant and represent direction relative to zero.

Step 2. Assign values. On (0, +∞) take 1. On (−∞, 0) take −1. At 0 take 0 to preserve oddness and to avoid pretending zero is positive or negative.

Step 3. Quotient form. For x ≠ 0, |x| is positive, so x/|x| has sign equal to x and magnitude 1. Hence sgn(x) = x/|x|. At x = 0 the formula fails — hence the separate clause sgn(0) = 0.

Step 4. Computed by comparisons. The predicates x > 0 and x < 0 are disjoint; when both are false, x = 0 (for a real finite input). The ternary x>0?1:x<0?−1:0 therefore realizes the definition without division.

Step 5. Worked numbers on this page. For x = 5, 5 > 0 so the result is 1. For x = −3, −3 < 0 so the result is −1. For x = 0 the result is 0. The panel also shows |x|, the product x·sgn(x), and Math.sign(x) for comparison.

Special cases

Positives: every x > 0, including 0.1 and large 1e6, yields 1. Negatives: every x < 0, including −0.1 and −3.5, yields −1. Zero: the only 0 in this convention. Integers vs non-integers do not change the rule — only the side of zero matters.

Versus |x|: |−3| = 3, but sgn(−3) = −1. Versus floor: ⌊−3.2⌋ = −4, sgn(−3.2) = −1. Versus Math.sign on ordinary −3: both paths give −1; the difference appears with the signed zero of floating-point arithmetic, which this form field does not expose as a separate primary-result state.

On complex numbers one often sets sgn(z) = z/|z| for z ≠ 0 (a point on the unit circle). This calculator does not compute that — only a real x from one field.

Numerical notes

The browser reads a comma or period input as a number. The ternary compares x with zero in computer arithmetic 754 arithmetic. For finite x the result matches mathematical sgn. NaN and infinities are not accepted as valid inputs — the calculator requires a finite real.

Math.sign appears in the supporting panel. In JavaScript, Math.sign(x) may return 1, −1, +0, −0, or NaN. This page does not call Math.sign for the primary result; a field zero yields 0.

Very small |x| (for example 1e−20) is still positive or negative, so sgn stays ±1 — there is no sensitivity threshold other than exact zero. Smooth signum approximations are a different numerical model, not this page.

Related notions and sources

Related on this site: absolute value |x|, floor, fractional part. In theory: Heaviside step, derivative of |x|, and 1-D direction (±1).

Sources: Wikipedia — Sign function; MathWorld — Sign; ECMAScript — Math.sign; the identity |x| = x·sgn(x) for x ≠ 0 in standard analysis texts. Educational tool.

How to use

  1. Enter x in the Number x field, for example 5, −3, or 0.
  2. Click Calculate or wait for the live result. 5 gives 1. −3 gives −1. 0 gives 0.
  3. Check the panel: |x|, side of zero, Math.sign(x), and the product x·sgn(x). The diagram marks x on the line.
  4. Fractions 0.1 and −0.1 give ±1. −3.5 gives −1.
  5. Absolute value is on the sibling |x| page. Here you stay with the sign alone.

Symbol glossary

Signum returns the sign: 1, −1, or 0. sgn(5) = 1. sgn(−3) = −1. sgn(0) = 0. This is not |x|.

sgn(x)
Sign function: a result in {−1, 0, 1}. Primary result field.
x
Number in the “Number x” field. 5, −3, 0, 0.1…
|x|
Absolute value: magnitude without sign. For x ≠ 0: |x| = x · sgn(x).
Math.sign
JavaScript function in the comparison panel. The primary result uses the ternary, not Math.sign.

Examples

Example 1

  • x = 5

1

What is sgn(5)? 1 (|5| = 5).

Example 2

  • x = −3

−1

What is sgn(−3)? −1 (|−3| = 3).

Example 3

  • x = 0

0

What is sgn(0)? 0 (convention).

Example 4

  • x = 0.1

1

What is sgn(0.1)? 1 (small positive).

Example 5

  • x = −0.1

−1

What is sgn(−0.1)? −1 (small negative).

Example 6

  • x = −3.5

−1

What is sgn(−3.5)? −1 (magnitude drops out).

Related calculators

Frequently asked questions

What does sgn(x) (signum, sign of a number) mean?

sgn(x) is the sign function: 1 for x > 0, −1 for x < 0, and 0 for x = 0. The result lies in {−1, 0, 1}. This is not absolute value |x|.

How does the calculator compute the result?

With the ternary x>0?1:x<0?−1:0 — the same path as the page formula. The primary result does not call Math.sign; Math.sign appears only in the comparison panel.

How is signum different from absolute value |x|?

|x| keeps magnitude and drops sign (|−3| = 3). sgn(x) keeps sign and drops magnitude (sgn(−3) = −1). For x ≠ 0, |x| = x · sgn(x).

What is sgn(0), and why not ±1?

On this page sgn(0) = 0. Zero is neither positive nor negative. The quotient x/|x| is undefined at zero, so the convention sets the separate value 0.

Do Math.sign and the ternary always agree?

For ordinary finite x ≠ 0 — yes (±1). The difference concerns the signed zero of floating-point arithmetic: Math.sign(−0) returns −0, while a field zero here yields result 0.

Does a comma in −3.5 work?

Yes. −3,5 and −3.5 are the same negative x, so the result is −1. The field accepts both locale styles.

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

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

Where do I compute |x| or floor?

Absolute value is on the |x| page. Integer part ⌊x⌋ is on the floor page. Here you stay with the sign sgn(x) alone.

Do fractions 0.1 and −0.1 give ±1?

Yes. Every x > 0 gives 1, including 0.1. Every x < 0 gives −1, including −0.1. Magnitude does not change the result.

Where does the sgn definition come from?

It is the standard signum function from analysis and school algebra (Wikipedia Sign function, MathWorld Sign). The identity |x| = x·sgn(x) for x ≠ 0 is textbook. Here the calculator uses comparisons, not division by |x|.

How do I calculate the sign of a number (signum)?

If x > 0 the result is 1; if x < 0 it is −1; if x = 0 it is 0. For 5 you get 1; for −3 you get −1.

What is sgn(5)?

1. Every x > 0 gives the same result. That is the first example on this page.

What is sgn(−3)?

−1. The magnitude 3 is not part of the primary result — |−3| lives on the absolute-value page.

Is this complex-number signum?

No. The domain here is the reals. For z ≠ 0 in ℂ one often takes z/|z|; that formula is not this page’s model.

Is this the sign of a permutation?

No. The sign of a permutation (±1 by parity) is a different function. Here the result is the sign of one real number x.

The result is sgn(x): for x = 5 it is 1; for x = −3 it is −1; for x = 0 it is 0. Compute |x| on the sibling absolute-value page.

Sources

The sgn definition, the link to |x|, and the Math.sign comparison come from recognized sources.

Page updated November 3, 2026.