1 |
|
2 |
|
3 | # Function isNumeric
|
4 |
|
5 | Test whether a value is an numeric value.
|
6 |
|
7 | The function is evaluated element-wise in case of Array or Matrix input.
|
8 |
|
9 |
|
10 | ## Syntax
|
11 |
|
12 | ```js
|
13 | math.isNumeric(x)
|
14 | ```
|
15 |
|
16 | ### Parameters
|
17 |
|
18 | Parameter | Type | Description
|
19 | --------- | ---- | -----------
|
20 | `x` | * | Value to be tested
|
21 |
|
22 | ### Returns
|
23 |
|
24 | Type | Description
|
25 | ---- | -----------
|
26 | boolean | Returns true when `x` is a `number`, `BigNumber`, `Fraction`, or `boolean`. Returns false for other types. Throws an error in case of unknown types.
|
27 |
|
28 |
|
29 | ## Examples
|
30 |
|
31 | ```js
|
32 | math.isNumeric(2) // returns true
|
33 | math.isNumeric('2') // returns false
|
34 | math.hasNumericValue('2') // returns true
|
35 | math.isNumeric(0) // returns true
|
36 | math.isNumeric(math.bignumber(500)) // returns true
|
37 | math.isNumeric(math.fraction(4)) // returns true
|
38 | math.isNumeric(math.complex('2-4i') // returns false
|
39 | math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
|
40 | ```
|
41 |
|
42 |
|
43 | ## See also
|
44 |
|
45 | [isZero](isZero.md),
|
46 | [isPositive](isPositive.md),
|
47 | [isNegative](isNegative.md),
|
48 | [isInteger](isInteger.md),
|
49 | [hasNumericValue](hasNumericValue.md)
|