cookie clicker but bigger
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

56 líneas
1.2 KiB

  1. function render(val, places = 1, smallPlaces = 0) {
  2. return numberMode.render(val, places, smallPlaces);
  3. }
  4. function numberText(val, places = 1, smallPlaces = 0) {
  5. if (isNaN(val)) {
  6. throw new RangeError("Invalid number: " + val);
  7. }
  8. if (val < 1000) {
  9. return round(val, smallPlaces);
  10. }
  11. let power = Math.floor(Math.log10(val));
  12. let order = Math.floor(power / 3);
  13. adjusted = round(val / Math.pow(1000, order), places).toFixed(places);
  14. if (order <= 21)
  15. return adjusted + " " + _numberWords[order - 1];
  16. else
  17. return numberText(val / Math.pow(10, 63), places, smallPlaces) + " vigintillion"
  18. }
  19. _numberWords = {
  20. 0: "thousand",
  21. 1: "million",
  22. 2: "billion",
  23. 3: "trillion",
  24. 4: "quadrillion",
  25. 5: "quintillion",
  26. 6: "sextillion",
  27. 7: "septillion",
  28. 8: "octillion",
  29. 9: "nonillion",
  30. 10: "decillion",
  31. 11: "undecillion",
  32. 12: "duodecillion",
  33. 13: "tredecillion",
  34. 14: "quattuordecillion",
  35. 15: "quindecillion",
  36. 16: "sexdecillion",
  37. 17: "septendecillion",
  38. 18: "octodecillion",
  39. 19: "novemdecillion",
  40. 20: "vigintillion",
  41. }
  42. function numberScientific(val, places = 1, smallPlaces) {
  43. return val.toExponential(places)
  44. }
  45. function numberFull(val, places = 1, smallPlaces) {
  46. return round(val, places);
  47. }