better handling of large values (#678)

This commit is contained in:
Xiliang Chen 2019-02-11 05:48:13 +13:00 committed by Jaco Greeff
parent 76537ffc0a
commit b415ab847d

View File

@ -46,7 +46,7 @@ const SI_MID = 8;
let defaultDecimals = 0;
export function calcSi (text: string, decimals: number = defaultDecimals): SiDef {
return SI[(SI_MID - 1) + Math.ceil((text.length - decimals) / 3)];
return SI[(SI_MID - 1) + Math.ceil((text.length - decimals) / 3)] || SI[SI.length - 1];
}
// Formats a string/number with <prefix>.<postfix><type> notation