Function isInteger
Test whether a value is an integer number.
The function supports number
, BigNumber
, and Fraction
.
The function is evaluated element-wise in case of Array or Matrix input.
Syntax
isInteger(x)
Parameters
Parameter | Type | Description |
---|---|---|
x |
number | BigNumber | Fraction | Array | Matrix | Value to be tested |
Returns
Type | Description |
---|---|
boolean | Returns true when x contains a numeric, integer value. Throws an error in case of an unknown data type. |
Examples
isInteger(2); // returns true
isInteger(0); // returns true
isInteger(0.5); // returns false
isInteger(bignumber(500)); // returns true
isInteger(fraction(4)); // returns true
isInteger('3'); // returns true
isInteger([3, 0.5, -2]); // returns [true, false, true]
isInteger(complex('2-4i'); // throws an error