@pengzhanbo/utils - v3.5.1
    Preparing search index...

    Function decimalAdd

    • Precisely add two floating-point numbers

      精确相加两个数

      Parameters

      • a: number

        The first number. 第一个数字

      • b: number

        The second number. 第二个数字

      Returns number

      The sum of the two numbers. 两个数字的和

      addFloats(0.1, 0.2) // => 0.3
      addFloats(1.5, 2.3) // => 3.8
      addFloats(10.001, 20.002) // => 30.003

      The current implementation only considers predictable scenarios and cannot guarantee precise calculation results under all circumstances; For calculation scenarios involving large numbers, finance, science, etc., it is recommended to use open-source libraries such as decimal.js to handle mathematical operations.

      当前实现仅考虑可预期的场景,无法保证在所有情况下都能精确计算结果; 涉及到大数、金融、科学等计算场景,建议使用 decimal.js 等开源库来处理数学运算