Skip to content

Function: add()

ts
function add(a, b): number;

Adds two numbers with fixed precision to avoid floating point errors. 高精度加法运算,避免浮点数误差。

Parameters

ParameterTypeDescription
anumberThe first number to add / 第一个加数
bnumberThe second number to add / 第二个加数

Returns

number

The result of adding the two numbers / 加法结果

Example

typescript
add(0.1, 0.2) // => 0.3 (not 0.30000000000000004)
add(123.456, 78.9) // => 202.356

Since

1.0.0

Released under the MIT License.