unaryMinus.md (1058B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function unaryMinus 4 5 Inverse the sign of a value, apply a unary minus operation. 6 7 For matrices, the function is evaluated element wise. Boolean values and 8 strings will be converted to a number. For complex numbers, both real and 9 complex value are inverted. 10 11 12 ## Syntax 13 14 ```js 15 math.unaryMinus(x) 16 ``` 17 18 ### Parameters 19 20 Parameter | Type | Description 21 --------- | ---- | ----------- 22 `x` | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Number to be inverted. 23 24 ### Returns 25 26 Type | Description 27 ---- | ----------- 28 number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Returns the value with inverted sign. 29 30 31 ### Throws 32 33 Type | Description 34 ---- | ----------- 35 36 37 ## Examples 38 39 ```js 40 math.unaryMinus(3.5) // returns -3.5 41 math.unaryMinus(-4.2) // returns 4.2 42 ``` 43 44 45 ## See also 46 47 [add](add.md), 48 [subtract](subtract.md), 49 [unaryPlus](unaryPlus.md)