Explorar el Código

Fix missing quintillion, add numbers up to vigintillion, add compound numbers

tags/v0.0.3
Fen Dweller hace 5 años
padre
commit
3c602488f0
Se han modificado 1 ficheros con 22 adiciones y 8 borrados
  1. +22
    -8
      numbers.js

+ 22
- 8
numbers.js Ver fichero

@@ -11,20 +11,34 @@ function numberText(val, places=1, smallPlaces = 0) {

let order = Math.floor(power / 3);

val = round(val / Math.pow(1000, order), places).toFixed(places);
adjusted = round(val / Math.pow(1000, order), places).toFixed(places);

return val + " " + _numberWords[order];
if (order <= 21)
return adjusted + " " + _numberWords[order - 1];
else
return numberText(val / Math.pow(10, 63), places, smallPlaces) + " vigintillion"
}

_numberWords = {
1: "thousand",
2: "million",
3: "billion",
4: "trillion",
5: "quadrillion",
0: "thousand",
1: "million",
2: "billion",
3: "trillion",
4: "quadrillion",
5: "quintillion",
6: "septillion",
7: "sextillion",
8: "octillion",
9: "nonillion",
10: "decillion"
10: "decillion",
11: "undecillion",
12: "duodecillion",
13: "tredecillion",
14: "quattuordecillion",
15: "quindecillion",
16: "sexdecillion",
17: "septendecillion",
18: "octodecillion",
19: "novemdecillion",
20: "vigintillion",
}

Cargando…
Cancelar
Guardar