1 |
|
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 | ## Examples
|
32 |
|
33 | ```js
|
34 | math.unaryMinus(3.5) // returns -3.5
|
35 | math.unaryMinus(-4.2) // returns 4.2
|
36 | ```
|
37 |
|
38 |
|
39 | ## See also
|
40 |
|
41 | [add](add.md),
|
42 | [subtract](subtract.md),
|
43 | [unaryPlus](unaryPlus.md)
|