ConstFormat 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%
Floating-point ratio to convert.
Number of decimal places, defaulting to 0.
The percentage string.
Alias of
formatPercentage.