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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

visual studio - TFS will not accept changes I've made to a Java project -