mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
47 lines (31 loc) • 1.28 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
```js
math.numeric(x)
```
Parameter | Type | Description
--------- | ---- | -----------
`value` | string &
`outputType` | string | Desired numeric output type. Available values: 'number', 'BigNumber', or 'Fraction'
Type | Description
---- | -----------
number &
```js
math.numeric('4') // returns number 4
math.numeric('4', 'number') // returns number 4
math.numeric('4', 'BigNumber') // returns BigNumber 4
math.numeric('4', 'Fraction') // returns Fraction 4
math.numeric(4, 'Fraction') // returns Fraction 4
math.numeric(math.fraction(2, 5), 'number') // returns number 0.4
```
[ ](number.md),
[ ](fraction.md),
[ ](bignumber.md),
[ ](string.md),
[ ](format.md)