unaryMinus

-x

unaryMinus(x)

Try it yourself:

See also:

unaryMinus(): negate a value

unaryMinus(x) changes the sign of x. It is the operation behind the leading minus in -x.

Examples

Negating 5 gives −5; negating −5 gives 5. With matrices, every entry is negated.

Related arithmetic

Use subtract() for a difference between two values, unaryPlus() for explicit positive conversion, abs() for magnitude, and sign() for classification.

Caveat

Negation is not the same as taking a reciprocal. Use division or a negative exponent when that is required.

Try Unary Minus 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