textConvert
    Preparing search index...

    Function formatNumber

    • Formats a number with thousands separators, English/US style (comma thousands separator, period decimal point) -- not locale-aware, see numbersToWords's own docs for why.

      Parameters

      • number: number

        Number to format.

      • options: FormatNumberOptions = {}
        • Optionaldecimals?: number

          Number of decimal places to round/pad to. Omit to preserve the input's natural precision.

      Returns string

      The formatted number, or the shared invalid-input message for anything that isn't a finite number.

      formatNumber(1234567); // '1,234,567'
      formatNumber(1234567.89); // '1,234,567.89'
      formatNumber(1234.5, { decimals: 2 }); // '1,234.50'
      formatNumber(-1234.5); // '-1,234.5'