mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
955 B
955 B
Function unary
Inverse the sign of a value, apply a unary minus operation.
For matrices, the function is evaluated element wise. Boolean values will be converted to a number. For complex numbers, both real and complex value are inverted.
Syntax
math.unary(x)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | Number to be inverted. |
Returns
| Type | Description |
|---|---|
| Number | BigNumber | Complex | Unit | Array | Matrix | Returns the value with inverted sign. |
Examples
var math = mathjs();
math.unary(3.5); // returns -3.5
math.unary(-4.2); // returns 4.2