Hi again. I struck a bit of a problem with my program. I needed to take a number and then round it to the neerest half. After quite a while I finaly managed to hack it together but I was wondering if there is a cleaner way to do it?

Here is my bodged way of doing it:

Code:

float weight;
float remainder;
int whole;
weight = 11.24;
whole = weight / 1;
remainder = weight - whole;
if (remainder < 0.5)
if (remainder >= 0.25)
remainder = 0.5;
else
remainder = 0.0;
else
if (remainder >= 0.75)
remainder = 1.0;
else
remainder = 0.5;
weight = whole + remainder;

Thanks