isNegative 函数 #

测试一个值是否为负数:小于零。该函数支持 numberBigNumberFractionUnit 类型。

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

Syntax #

math.isNegative(x)

Parameters #

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

Returns #

Type Description
boolean x 大于零时返回 true。在遇到未知数据类型时抛出错误。

Throws #

Type | Description —- | ———–

Examples #

math.isNegative(3)                     // returns false
math.isNegative(-2)                    // returns true
math.isNegative(0)                     // returns false
math.isNegative(-0)                    // returns false
math.isNegative(math.bignumber(2))     // returns false
math.isNegative(math.fraction(-2, 5))  // returns true
math.isNegative('-2')                  // returns true
math.isNegative([2, 0, -3])            // returns [false, false, true]

另请参阅 #

isNumeric, isPositive, isZero, isInteger

Fork me on GitHub