UNPKG

1.28 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function numeric
4
5Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.
6
7
8## Syntax
9
10```js
11math.numeric(x)
12```
13
14### Parameters
15
16Parameter | Type | Description
17--------- | ---- | -----------
18`value` | string &#124; number &#124; BigNumber &#124; Fraction | A numeric value or a string containing a numeric value
19`outputType` | string | Desired numeric output type. Available values: 'number', 'BigNumber', or 'Fraction'
20
21### Returns
22
23Type | Description
24---- | -----------
25number &#124; BigNumber &#124; Fraction | Returns an instance of the numeric in the requested type
26
27
28## Examples
29
30```js
31math.numeric('4') // returns number 4
32math.numeric('4', 'number') // returns number 4
33math.numeric('4', 'BigNumber') // returns BigNumber 4
34math.numeric('4', 'Fraction') // returns Fraction 4
35math.numeric(4, 'Fraction') // returns Fraction 4
36math.numeric(math.fraction(2, 5), 'number') // returns number 0.4
37```
38
39
40## See also
41
42[number](number.md),
43[fraction](fraction.md),
44[bignumber](bignumber.md),
45[string](string.md),
46[format](format.md)