Function isInteger #

测试一个值是否为整数。该函数支持 numberBigNumberFraction

如果输入是数组或矩阵,函数将逐个元素进行评估。

Syntax #

math.isInteger(x)

Parameters #

Parameter Type Description
x number | BigNumber | bigint | Fraction | Array | Matrix 要测试的值

Returns #

Type Description
boolean x 包含数值整数值时返回 true。如果数据类型未知,则会抛出错误。

Throws #

Type | Description —- | ———–

Examples #

math.isInteger(2)                     // returns true
math.isInteger(0)                     // returns true
math.isInteger(0.5)                   // returns false
math.isInteger(math.bignumber(500))   // returns true
math.isInteger(math.fraction(4))      // returns true
math.isInteger('3')                   // returns true
math.isInteger([3, 0.5, -2])          // returns [true, false, true]
math.isInteger(math.complex('2-4i'))  // throws TypeError

另请参阅 #

isNumeric, isPositive, isNegative, isZero

Fork me on GitHub