mazey
    Preparing search index...

    Variable floatToPercentConst

    floatToPercent: (num: number, fixSize?: number) => string = formatPercentage

    Alias of formatPercentage.

    Type Declaration

      • (num: number, fixSize?: number): string
      • Format a numeric ratio as a percentage string.

        Multiply by 100. Falsy precision uses Math.floor, including for negative ratios; truthy precision uses native toFixed and preserves trailing zeros. Floating-point arithmetic and native precision conversion remain unchanged.

        Usage:

        import { formatPercentage } from "mazey";

        const ret1 = formatPercentage(0.2);
        const ret2 = formatPercentage(0.2, 2);
        console.log(ret1);
        console.log(ret2);

        Output:

        20%
        20.00%
        

        Parameters

        • num: number

          Floating-point ratio to convert.

        • fixSize: number = 0

          Number of decimal places, defaulting to 0.

        Returns string

        The percentage string.

        If native toFixed rejects a truthy precision value.

    Use formatPercentage instead.