Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Formatter myFormatter = new Formatter();
- double piOld = 3.14159265;
- int decimals = 4;
- double piFormatted = Double.parseDouble(myFormatter.formatNumber(piOld, decimals));
- System.out.println(piOld + " " + piFormatted);
- // Output
- // 3.14159265 3.1415
Add Comment
Please, Sign In to add comment