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

    Function decimalSubtract

    • Precisely subtract two floating-point numbers

      精确相减两个数

      Parameters

      • a: number

        The first number. 第一个数字

      • b: number

        The second number. 第二个数字

      Returns number

      The difference of the two numbers. 两个数字的差

      decimalMinus(0.1, 0.2) // => -0.1
      decimalMinus(1.5, 2.3) // => -1.8
      decimalMinus(10.001, 20.002) // => -19.999

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