Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1001 Bytes

README.md

File metadata and controls

37 lines (22 loc) · 1001 Bytes

Format SI

Format a number into SI metric prefixed value.

Usage

There are three different functions that converts a value into SI metric prefixed value.

formatSI()

Converts a number into the metric prefixed value.

Example:

formatSI(10000, "W"); // Returns { value: 10, unit: "kW" }

formatFixedSI()

Uses formatSI() to convert the number, but it adds .toFixed(fractionDigits) to the value.

Example:

formatFixedSI(10000 "W", 3,); // Returns { value: "10.000", unit: "kW" }

formatPrecisionSI()

Uses formatSI() to convert the number, but it adds .toPrecision(precision) to the value.

Example:

formatPrecisionSI(10000 "W", 3,); // Returns { value: "10.0", unit: "kW" }