I have a double value = 1.6 i want to round it up like 2.in java can some one Help me.
Asked
Active
Viewed 346 times
-7
-
2Please do some research before asking a question in the future. A simple google search for "rounding in java" would have been more than sufficient. – Mage Xy Feb 29 '16 at 18:17
4 Answers
1
Alternatively, if you want to round to the lowest decimal;
Math.floor(1.6)

Yağız Can Aslan
- 102
- 12

comjens
- 23
- 6
0
The general way for rounding in Java is this one. You can configure the scale to which you round as well as when you want to round up and when you want to round down:
new BigDecimal(value).setScale(1.0, RoundingMode.HALF_UP).doubleValue();

Matthias Wimmer
- 3,789
- 2
- 22
- 41