Guest User

Untitled

a guest
May 2nd, 2017
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.text.DecimalFormat;
  2.  
  3. public class DecimalFormatExample {
  4.  
  5.     public static void main(String[] args) {
  6.    
  7.         double number = 123.456;
  8.        
  9.         //15 digits after decimal point
  10.         DecimalFormat decimalFormat = new DecimalFormat(".000000000000000");
  11.         System.out.println(decimalFormat.format(number));
  12.        
  13.         //15 digits before and after decimal point
  14.         DecimalFormat decimalFormat2 = new DecimalFormat("000000000000000.000000000000000");
  15.         System.out.println(decimalFormat2.format(number));
  16.        
  17.         //15 digits after decimal point
  18.         System.out.printf("%.15f", number);
  19.     }
  20. }
RAW Paste Data