SHARE
TWEET

hope this works

a guest Jul 6th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Beautify(num,floats)
  2. {
  3. if (!isFinite(num)) return 'Infinity'
  4. if(num < 1e3) return Math.round(num)
  5. var i = 0;
  6. while(num >= 10)
  7. {
  8. num/=10;
  9. i++;
  10. }
  11. num = Math.round(num*100)/100;
  12. if(num>=10)
  13. {
  14. num/=10;
  15. i++;
  16. num = Math.round(num*100)/100;
  17. } //deals with rounding errors
  18. num = num.toFixed(2);
  19. return num + "e" + i
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top