Advertisement
Trevin

Javascript script!

May 24th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. tempNums1 = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'X', 'V', 'U', 'S', 'H', 'F', 'L', "W"];
  2. tempNums2 = ['', 'N', 'NN', 'NNN', 'NNNN', 'Q', 'NQ', 'NNQ', 'NNNQ', 'NNNNQ', 'QQ', 'NQQ', 'NNQQ', 'NNNQQ', 'NNNNQQ', 'QQQ', 'NQQQ', 'NNQQQ', 'NNNQQQ', 'NNNNQQQ', 'QQQQ',];
  3. nums = [];
  4. for (var i = 0; i < tempNums2.length; i++){
  5. for (var j = 0; j < tempNums1.length; j++){
  6. nums.push(tempNums1[j] + tempNums2[i]);
  7. };
  8. };
  9.  
  10. function Beautify(num,floats)
  11. {
  12. if (!isFinite(num)) return 'Infinity'
  13. var i = 1;
  14. while(num >= 1000)
  15. {
  16. num/=1000;
  17. i++;
  18. }
  19. num = Math.round(num*1000)/1000;
  20. if(num>=1000)
  21. {
  22. num/=1000;
  23. i++;
  24. num = Math.round(num*1000)/1000;
  25. } //deals with rounding errors
  26. num = num.toString();
  27. if(num.indexOf('.') == -1) num += '.000'
  28. else
  29. {
  30. dec = num.indexOf('.');
  31. while(num.slice(dec,num.length).length < 4) num += '0' //adds trailing 0s (if needed) to stop the numbers jumping around.
  32. }
  33. return num + nums[i - 1]
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement