UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

42 lines (24 loc) 877 B
# Function abs Calculate the absolute value of a number. For matrices, the function is evaluated element wise. ## Syntax ```js math.abs(x) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `x` | Number &#124; BigNumber &#124; Boolean &#124; Complex &#124; Array &#124; Matrix &#124; null | A number or matrix for which to get the absolute value ### Returns Type | Description ---- | ----------- Number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | Absolute value of `x` ## Examples ```js 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) <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->