Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Beautify(num,floats)
- {
- if (!isFinite(num)) return 'Infinity'
- if(num < 1e3) return Math.round(num)
- var i = 0;
- while(num >= 10)
- {
- num/=10;
- i++;
- }
- num = Math.round(num*100)/100;
- if(num>=10)
- {
- num/=10;
- i++;
- num = Math.round(num*100)/100;
- } //deals with rounding errors
- num = num.toFixed(2);
- return num + "e" + i
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement