UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

45 lines (27 loc) 1.02 kB
# Function unaryMinus Inverse the sign of a value, apply a unary minus operation. For matrices, the function is evaluated element wise. Boolean values and strings will be converted to a number. For complex numbers, both real and complex value are inverted. ## Syntax ```js math.unaryMinus(x) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `x` | Number &#124; BigNumber &#124; Boolean &#124; String &#124; Complex &#124; Unit &#124; Array &#124; Matrix &#124; null | Number to be inverted. ### Returns Type | Description ---- | ----------- Number &#124; BigNumber &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Returns the value with inverted sign. ## Examples ```js math.unaryMinus(3.5); // returns -3.5 math.unaryMinus(-4.2); // returns 4.2 ``` ## See also [add](add.md), [subtract](subtract.md), [unaryPlus](unaryPlus.md) <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->