Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "34.49596" would be "34.4959"
- "49.3" would be "49.30"
- DecimalFormat df = new DecimalFormat("0.00##");
- String result = df.format(34.4959);
- double a = 34.51234;
- NumberFormat df = DecimalFormat.getInstance();
- df.setMinimumFractionDigits(2);
- df.setMaximumFractionDigits(4);
- df.setRoundingMode(RoundingMode.DOWN);
- System.out.println(df.format(a));
Add Comment
Please, Sign In to add comment