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.

All functions