How to round integer in java

后端 未结 12 861
野趣味
野趣味 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:29

    very simple. try this

    int y = 173256457;int x = (y/10)*10; 
    

    Now in this you can replace 10 by 100,1000 and so on....

提交回复
热议问题