Guest User

Untitled

a guest
Oct 7th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. public class math_utils {
  2.    
  3.     private static String[] k = new String[] {"", "k", "m", "b", "t", "B", "T", "A", "C", "D", "E", "F"};
  4.    
  5.     public static String parsed(double d) {
  6.        
  7.         int i = 0;
  8.         while(d>=1000) {
  9.             i++;
  10.             d/=1000;
  11.         }
  12.         char c = 0;
  13.         String fd = new DecimalFormat("#0.00").format(d);
  14.         if(fd.charAt(2) == c) {
  15.             fd = new DecimalFormat("#0").format(d);
  16.         }
  17.         return fd+k[i];
  18.     }
  19.    
  20. }
Add Comment
Please, Sign In to add comment