rounding to intervals of 5000
Hey, can anyone give me some advice. I have a number
for example 651004. I need to round it to the closest interval of 5000
ex) 651004 -> 650000 while 655250 -> 655000 and 689880 -> 700000
i've been coding an algorithm that is just getting way too messy. can somebody please help me?
[320 byte] By [
celfiea] at [2007-11-27 0:59:33]

> Hey, can anyone give me some advice. I have a number
>
> for example 651004. I need to round it to the closest
> interval of 5000
> ex) 651004 -> 650000 while 655250 -> 655000 and
> 689880 -> 700000
> i've been coding an algorithm that is just getting
> way too messy. can somebody please help me?
number + 4999 (this number will depend on which way 12500 will go that is if it's round up or down)
int temp = number / 5000 (make sure these are ints)
number = temp * 5000;
Ps check the bolded part i'm pretty sure that is a typo