Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. nums = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'BB', 'CC, 'DD', 'EE', 'FF', 'GG', 'HH', 'II'];
  2.  
  3.  
  4. function Beautify(num,floats)
  5. {
  6. if (!isFinite(num)) return 'Infinity'
  7. if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length))) return Math.round(num)
  8. var i = 0;
  9. while(num >= 1000)
  10. {
  11. num/=1000;
  12. i++;
  13. }
  14. num = Math.round(num*1000)/1000;
  15. if(num>=1000)
  16. {
  17. num/=1000;
  18. i++;
  19. num = Math.round(num*1000)/1000;
  20. } //deals with rounding errors
  21. num = num.toFixed(3);
  22. return num + nums[i - 1]
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement