Function unequal #
测试两个值是否不相等。
该函数测试 x 和 y 之间的相对差是否大于配置的 relTol 和 absTol。该函数不能用于比较小于约 2.22e-16 的值。
对于矩阵,该函数逐元素进行评估。对于复数,x.re 必须不等于 y.re,或者 x.im 必须不等于 y.im。字符串按其数值进行比较。
值 null 和 undefined 进行严格比较,因此 null 与除 null 之外的所有值都不相等,而 undefined 与除 undefined 之外的所有值都不相等。
Syntax #
math.unequal(x, y)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined | 要比较的第一个值 |
y |
number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined | 要比较的第二个值 |
Returns #
| Type | Description |
|---|---|
| boolean | Array | Matrix | 当比较的值不相等时返回 true,否则返回 false |
Throws #
Type | Description —- | ———–
Examples #
math.unequal(2 + 2, 3) // returns true
math.unequal(2 + 2, 4) // returns false
const a = math.unit('50 cm')
const b = math.unit('5 m')
math.unequal(a, b) // returns false
const c = [2, 5, 1]
const d = [2, 7, 1]
math.unequal(c, d) // returns [false, true, false]
math.deepEqual(c, d) // returns false
math.unequal(0, null) // returns true
另请参阅 #
equal, deepEqual, smaller, smallerEq, larger, largerEq, compare