Guest User

Untitled

a guest
Oct 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. Formatter myFormatter = new Formatter();
  2.  
  3. double piOld = 3.14159265;
  4. int decimals = 4;
  5. double piFormatted = Double.parseDouble(myFormatter.formatNumber(piOld, decimals));
  6.  
  7. System.out.println(piOld + " " + piFormatted);
  8.  
  9.  
  10. // Output
  11. // 3.14159265 3.1415
Add Comment
Please, Sign In to add comment