|
|
|
@@ -2,6 +2,26 @@ function render(val, places = 1, 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 < 1000) { |
|
|
|
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); |
|
|
|
|