function render(val, places = 3, smallPlaces = 0) { return numberMode.render(val, places, smallPlaces); } function numberTextSmall(val, places = 1, smallPlaces = 0) { if (isNaN(val)) { throw new RangeError("Invalid number: " + val); } if (val < Math.pow(10, (places+3))) { return round(val, smallPlaces); } let power = Math.floor(Math.log10(val)); let order = Math.floor(power / 3); adjusted = round(val / Math.pow(1000, order), places).toFixed(places); if (order <= 8) return adjusted + " " + _numberWords[order - 1]; else return numberTextSmall(val / Math.pow(10, 24), places, smallPlaces) + " septillion" } function numberText(val, places = 1, smallPlaces = 0) { if (isNaN(val)) { throw new RangeError("Invalid number: " + val); } if (val < Math.pow(10, (places+3))) { return round(val, smallPlaces); } let power = Math.floor(Math.log10(val)); let order = Math.floor(power / 3); adjusted = round(val / Math.pow(1000, order), places).toFixed(places); if (order <= 21) return adjusted + " " + _numberWords[order - 1]; else return numberText(val / Math.pow(10, 63), places, smallPlaces) + " vigintillion" } _numberWords = { 0: "thousand", 1: "million", 2: "billion", 3: "trillion", 4: "quadrillion", 5: "quintillion", 6: "sextillion", 7: "septillion", 8: "octillion", 9: "nonillion", 10: "decillion", 11: "undecillion", 12: "duodecillion", 13: "tredecillion", 14: "quattuordecillion", 15: "quindecillion", 16: "sexdecillion", 17: "septendecillion", 18: "octodecillion", 19: "novemdecillion", 20: "vigintillion", } function numberScientific(val, places = 1, smallPlaces) { return val.toExponential(places) } function numberFull(val, places = 1, smallPlaces) { return round(val, places); }