1. Originally Posted by iMalc
The answer with rounding should be 1.56, not 1.55
times 100

1.5555 * 100 = 155.55

round

156

divide by 100

1.56

2. Originally Posted by iMalc
The answer with rounding should be 1.56, not 1.55
And conveniently, that's what you get. (Or at least that's what I got, when I did it.)

3. And of course, it should be noted that due to the inaccuracy of floats, you still might not get exactly the answer you expect.

For instance, round( 1.234 * 100.0 ) / 100.0 might give 1.229999999, which would be printed as 1.22 if you are limiting the number of digits.

But that's just the way the cookie crumbles.

4. Bleh - brainfart. For ome reason I thought it didn't mention rounding.

5. Code:
```int round(double f)
{
unsigned int i = fabs(f*2);
if(i&1)
{
if(f>0)
{
return (int)++f;
}
return (int)--f;

}
else
{
return (int)f;
}
}```
i don't have a need for rounding to a particular number of decimal points, just to intelligently convert floats into ints.

this seems to do the trick, but i thought i'd throw it up in case someone can spot a problem.