-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
  • 90,369
  • 161
  • 124
  • 175
sathish anish
  • 443
  • 1
  • 5
  • 15
  • 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)