@leanchuck/core - v0.1.1
    Preparing search index...

    Function toPercentage

    • Normalizes a ratio into a percentage value rounded to a fixed precision.

      The value is kept on a 0–1 scale (i.e. 0.2525 represents 25.25%) so it stays composable with other math; use toPercentString for display.

      Parameters

      • value: number

        A ratio, typically between 0 and 1.

      • places: number = 4

        Decimal places to keep. Defaults to 4.

      Returns number

      The rounded ratio, or 0 when the input is not finite.

      toPercentage(1 / 3);    // 0.3333