How to round integer in java

后端 未结 12 774
野趣味
野趣味 2020-12-09 09:19

I want to round the number 1732 to the nearest ten, hundred and thousand. I tried with Math round functions, but it was written only for float and double. How to do this for

12条回答
  •  囚心锁ツ
    2020-12-09 09:50

        int val2 = 1732;
        val2 = (int)(Math.rint((double) i / 10) * 10);
    

    The output is:1730

提交回复
热议问题