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

    Function decimalMultiply

    • Precisely multiply two floating-point numbers

      精确相乘两个数

      Parameters

      • a: number

        The first number. 第一个数字

      • b: number

        The second number. 第二个数字

      Returns number

      The product of the two numbers. 两个数字的积

      decimalMultiply(0.1, 0.2) // => 0.02
      decimalMultiply(1.5, 2.3) // => 3.45
      decimalMultiply(10.001, 20) // => 200.02

      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 等开源库来处理数学运算