函数 subtract #

减去两个值,x - y。对于矩阵,该函数逐元素计算。

Syntax #

math.subtract(x, y)

Parameters #

Parameter Type Description
x number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix 初始值
y number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix 从中减去值 x

Returns #

Type Description
number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix xy 的减法

Throws #

Type | Description —- | ———–

Examples #

math.subtract(5.3, 2)        // returns number 3.3

const a = math.complex(2, 3)
const b = math.complex(4, 1)
math.subtract(a, b)          // returns Complex -2 + 2i

math.subtract([5, 7, 4], 4)  // returns Array [1, 3, 0]

const c = math.unit('2.1 km')
const d = math.unit('500m')
math.subtract(c, d)          // returns Unit 1.6 km

另请参阅 #

add

Fork me on GitHub