math - How would one round any integer to the next highest hundred in Java? -
to illustrate, i'd find out best way round following integers:
(integer) -> (rounded value)
9 -> 100
200 -> 200
201 -> 300
1367 -> 1400
...so on , forth... suggestions on best way accomplish using java?
determine modulus 100
int k = 1234; int mod = k % 100; //mod = 34 int difference = 100 - mod; //difference = 66 k += difference;
straightforward.
Comments
Post a Comment