sign

sign(x)

Try it yourself:

See also:
abs

Identify a number’s direction with sign

sign(x) returns -1 for a negative value, 0 for zero, and 1 for a positive value. It is useful in piecewise formulas, direction vectors, and threshold logic.

Example

sign(-4.2) is -1. Pair it with abs to separate magnitude from direction, or use isPositive and isNegative when a Boolean test is clearer.

Caveats

Near-zero floating-point values may not be exactly zero; define a tolerance in measurement workflows. Complex numbers do not have the same simple ordering as reals. Use compare for pairwise ordering of suitable values.

Try Sign in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions