isNaN 函数 #
测试一个值是否为 NaN(非数字)。该函数支持 number、BigNumber、Fraction、Unit 和 Complex 类型。
如果输入是数组或矩阵,函数将逐个元素进行评估。
Syntax #
math.isNaN(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | bigint | Fraction | Unit | Array | Matrix | 要测试的值 |
Returns #
| Type | Description |
|---|---|
| boolean | 当 x 为 NaN 时返回 true。在遇到未知数据类型时抛出错误。 |
Throws #
Type | Description —- | ———–
Examples #
math.isNaN(3) // returns false
math.isNaN(NaN) // returns true
math.isNaN(0) // returns false
math.isNaN(math.bignumber(NaN)) // returns true
math.isNaN(math.bignumber(0)) // returns false
math.isNaN(math.fraction(-2, 5)) // returns false
math.isNaN('-2') // returns false
math.isNaN([2, 0, -3, NaN]) // returns [false, false, false, true]
另请参阅 #
isNumeric、isNegative、isPositive、isZero、isInteger、isFinite、isBounded