函数 smaller #

测试值 x 是否小于 y。

当 x 小于 y 且 x 和 y 之间的相对差小于配置的 relTol 和 absTol 时,函数返回 true。该函数不能用于比较小于大约 2.22e-16 的值。

对于矩阵,该函数是逐元素计算的。字符串按其数值大小进行比较。

Syntax #

math.smaller(x, y)

Parameters #

Parameter Type Description
x number | BigNumber | bigint | Fraction | boolean | Unit | string | Array | Matrix 要比较的第一个值
y number | BigNumber | bigint | Fraction | boolean | Unit | string | Array | Matrix 要比较的第二个值

Returns #

Type Description
boolean | Array | Matrix 当 x 小于 y 时返回 true,否则返回 false

Throws #

Type | Description —- | ———–

Examples #

math.smaller(2, 3)            // returns true
math.smaller(5, 2 * 2)        // returns false

const a = math.unit('5 cm')
const b = math.unit('2 inch')
math.smaller(a, b)            // returns true

另请参阅 #

equal, unequal, smallerEq, smaller, smallerEq, compare

Fork me on GitHub