Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. // import java.text.DecimalFormat;
  2.    
  3.     private static String doubleToStringCSharpLike(double value) {
  4.         int digits = 15;
  5.  
  6.         DecimalFormat df = new DecimalFormat("0.#");
  7.         df.setMaximumFractionDigits(digits);
  8.  
  9.         if (Math.abs(value) >= 1d) {
  10.             digits -= df.format(value).split("[.,]")[0].length();
  11.         }
  12.  
  13.         df.setMaximumFractionDigits(digits);
  14.         return df.format(value);
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement