si-number
Formats numbers using SI prefixes.
Options
You can pass a configuration object as second parameter with the following keys:
- decimal: Symbol to use for decimal point (default:
.
). - precision: Number of decimal digits to show (default:
2
). - separator: Separator between digits and prefix (default: empty string).
- thousands: It
true
, only uses prefixes that are multiples of 1000.
Usage
const siNumber = ; // 2.5 centimeters, without thousands scale.console; // 2.5cm// 2.5 centimeters, using thousands scale.console; // 25,0mm