UNPKG

969 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function sign
4
5Compute the sign of a value. The sign of a value x is:
6
7- 1 when x > 0
8- -1 when x < 0
9- 0 when x == 0
10
11For matrices, the function is evaluated element wise.
12
13
14## Syntax
15
16```js
17math.sign(x)
18```
19
20### Parameters
21
22Parameter | Type | Description
23--------- | ---- | -----------
24`x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix &#124; Unit | The number for which to determine the sign
25
26### Returns
27
28Type | Description
29---- | -----------
30number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix &#124; Unit | e The sign of `x`
31
32
33## Examples
34
35```js
36math.sign(3.5) // returns 1
37math.sign(-4.2) // returns -1
38math.sign(0) // returns 0
39
40math.sign([3, 5, -2, 0, 2]) // returns [1, 1, -1, 0, 1]
41```
42
43
44## See also
45
46[abs](abs.md)
47
\No newline at end of file