isZero 函数 #

测试一个值是否为零。该函数可以检查 numberBigNumberFractionComplexUnit 类型的零。

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

Syntax #

math.isZero(x)

Parameters #

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

Returns #

Type Description
boolean x 为零时返回 true。对于未知数据类型会抛出错误。

Throws #

Type | Description —- | ———–

Examples #

math.isZero(0)                      // returns true
math.isZero(2)                      // returns false
math.isZero(0.5)                    // returns false
math.isZero(math.bignumber(0))      // returns true
math.isZero(math.fraction(0))       // returns true
math.isZero(math.fraction(1,3))     // returns false
math.isZero(math.complex('2 - 4i')) // returns false
math.isZero(math.complex('0i'))     // returns true
math.isZero('0')                    // returns true
math.isZero('2')                    // returns false
math.isZero([2, 0, -3])             // returns [false, true, false]

另请参阅 #

isNumeric, isPositive, isNegative, isInteger

Fork me on GitHub