accounting-js - v2.0.3
    Preparing search index...

    Function toFixed

    • Implementation of toFixed() that treats floats more like decimals.

      Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') that present problems for accounting- and finance-related software.

      Usage:

      // Native toFixed has rounding issues
      (0.615).toFixed(2);
      // => '0.61'

      // With accounting-js
      toFixed(0.615, 2);
      // => '0.62'

      Parameters

      • value: number

        Float to be treated as a decimal number

      • Optionalprecision: number

        Number of decimal digits to keep

      • Optionalround: number

        Decide round direction

      Returns string

      • Given number transformed into a string with the given precission