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