numerica
    Preparing search index...

    Function toAbbreviated

    • Converts a number to an abbreviated string format with suffixes like 'k', 'm', 'b', etc.

      Parameters

      • n: number

        The number to abbreviate

      • options: Options = {}

        Configuration options

        • decimals

          Number of decimal places to display (default: 1)

        • trim

          Whether to display trailing zeros (default: true)

      Returns string

      The abbreviated number as a string

      toAbbreviated(1500)           // "1.5k"
      toAbbreviated(2500000) // "2.5m"
      toAbbreviated(1000000, {decimals: 2, trim: true}) // "1m"
      toAbbreviated(1000000, {decimals: 2, trim: false}) // "1.00m"
      toAbbreviated(1234567, {decimals: 0}) // "1m"
      toAbbreviated(500) // "500"
      toAbbreviated(-3400) // "-3.4k"