Skip to content

Latest commit

 

History

History
42 lines (24 loc) · 803 Bytes

File metadata and controls

42 lines (24 loc) · 803 Bytes

ts-humanize v1.0.0


ts-humanize / computeSI

Function: computeSI()

computeSI(input, roundTo?): [number, SI_PREFIXES]

Defined in: SI-Units/SI.ts:20

Finds the most appropriate SI prefix for the given number and returns the prefix along with the value adjusted to be within that prefix

Will round to a maximum of roundTo decimal places (default: 6).

See also: SI, parseSI

Parameters

input

number

roundTo?

number = 6

Number of decimal places to round to (default: 6)

Returns

[number, SI_PREFIXES]

Example

computeSI(2.2345e-12) // [2.2345, "p"]
computeSI(1234567, 2) // [1.23, "M"]