-3

I'm trying to convert a decimal to a rounded value. I need the easiest way to round the value.

For example, my sample values:

12.63
4.12
22.00
7.96
0.15

Expected result:

13
5
22
8
1
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
sathish anish
  • 463
  • 1
  • 5
  • 17
  • Does this answer your question? [How to round a number to n decimal places in Java](https://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java) – Pramod H G Apr 26 '21 at 05:00

1 Answers1

0

It's simple. You can use Java Math class for this. Math.ceil() method rounds off the specified double value and you can then convert it to int by using type casting.

(int)Math.ceil(double value)