UNPKG

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