This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const posPrefix = ["", "k", "M", "G", "T", "P"] | |
const negPrefix = ["", "m", "μ", "n", "p", "a"] | |
/** | |
* Convert a number to a metric string in engineering/SI notation. For example, | |
* toMetric(1.2345678e8, "Wh", 4) returns "123.5MWh". | |
* @param value The number to convert to a string. | |
* @param unit A string representing the unit to use e.g. kW, C, V expected | |
* @param The total number of digits to return | |
*/ |
OlderNewer