Advertisement
Hexagram1209

round

Mar 29th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.14 KB | None | 0 0
  1. double d = 2.555;
  2. BigDecimal bd = new BigDecimal(d);
  3. BigDecimal rounded = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
  4. System.out.println(rounded);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement