r/javahelp • u/zetayshow • Sep 02 '20
Unsolved Math.round() rounding properties
Good morning Reddit, So I’m using math round to round some ints. Everything is fine except that if I try to round 445 it rounds to 450. This behavior is fine and acceptable but I’m trying to round to the hundredth digit. This means I want 445 to become 500 from going 445 to 450 and then 500. Is this possible with math round and anyone knows how? I’ve already been on google and stackoverflow but can’t find nothing that worked...
Thanks in advance!
23
Upvotes
11
u/sinistergroupon Sep 02 '20
As stated in the other comment round just does the decimal digits. If you want to round at the hundred level then divide by 100, run it through round then multiply by 100.