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]
# 1
http://www.regdeveloper.co.uk/2006/08/12/floating_point_approximation/
cooper6a at 2007-7-11 23:33:57 > top of Java-index,Java Essentials,Java Programming...
# 2

> 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

Aknibbsa at 2007-7-11 23:33:57 > top of Java-index,Java Essentials,Java Programming...
# 3
> http://www.regdeveloper.co.uk/2006/08/12/floating_poin> t_approximation/That's nice and all but what does it have to do with rounding numbers that appear to all be integers ?
Aknibbsa at 2007-7-11 23:33:57 > top of Java-index,Java Essentials,Java Programming...