2014-02-16 17:49:57 +01:00

40 lines
710 B
Markdown

# Function abs
Calculate the absolute value of a number.
## Syntax
```js
math.abs(x)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
`x` | Number | BigNumber | Boolean | Complex | Array | Matrix | A number or matrix for which to get the absolute value
### Returns
Type | Description
---- | -----------
Number | BigNumber | Complex | Array | Matrix | Absolute value of `x`
## Examples
```js
var math = mathjs();
math.abs(3.5); // returns Number 3.5
math.abs(-4.2); // returns Number 4.2
math.abs([3, -5, -1, 0, 2]); // returns Array [3, 5, 1, 0, 2]
```
## See also
[sign](sign.md)