Skip to content

Function: multiply()

ts
function multiply(a, b): number;

Multiplies two numbers with fixed precision. 高精度乘法运算,避免浮点数误差。

Parameters

ParameterTypeDescription
anumberThe first number to multiply / 第一个乘数
bnumberThe second number to multiply / 第二个乘数

Returns

number

The result of multiplying the two numbers / 乘法结果

Example

typescript
multiply(0.1, 0.2) // => 0.02 (not 0.020000000000000004)
multiply(1.23, 4.56) // => 5.6088

Since

1.0.0

Released under the MIT License.