Rounding Numbers to hundreds

Hi everyone,

I have made a random number generator to create a number between 1000 and 9000, but I always get numbers with many 10s and units. I want to round them 100s.

Is there any way to do this?
x -= x % 100;
Thanks, but it always floors the number. Is there a way to make it round numbers with 10s less than 5 down and numbers with 10s greater than or equal to 5 up?
This works for positive integers.
 
x = (x + 50) / 100 * 100
Thanks, it worked.
Topic archived. No new replies allowed.