Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nums = ['k','m','b', 't', 'q', 'Q', 's', 'S', 'O', 'N', 'D', 'UD', 'DD', 'TD', 'qD', 'QD', 'sD', 'SD', 'OD', 'ND', 'V', 'UV', 'DV', 'TV', 'qV', 'QV', 'sV', 'SV', 'OV', 'NV', 'T', 'UT', 'DT', 'TT', 'qT', 'QT', 'sT', 'ST', 'OT', 'NT', '~q', 'Uq', 'Dq', 'Tq', 'c', 'C', 'n', 'd', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz', 'AA', 'BB', 'CC', 'DD', 'EE','FF', 'GG','HH','II','JJ','KK','LL','MM','NN','OO','PP','QQ','RR','SS','TT','UU','VV','WW','XX','YY','ZZ','aaa',];
- function Beautify(num,floats)
- {
- if (!isFinite(num)) return 'Infinity'
- if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length))) return Math.round(num)
- var i = 0;
- while(num >= 1000)
- {
- num/=1000;
- i++;
- }
- num = Math.round(num*1000)/1000;
- if(num>=1000)
- {
- num/=1000;
- i++;
- num = Math.round(num*1000)/1000;
- } //deals with rounding errors
- num = num.toString();
- if(num.indexOf('.') == -1) num += '.000'
- else
- {
- dec = num.indexOf('.');
- while(num.slice(dec,num.length).length < 4) num += '0' //adds trailing 0s (if needed) to stop the numbers jumping around.
- }
- return num + nums[i - 1]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement