Hi,
I was wondering if anyone knew of a function that could do rounding to the nearest whole number?
e.g 1.32 -> 1
1.53->2
Thanks
Printable View
Hi,
I was wondering if anyone knew of a function that could do rounding to the nearest whole number?
e.g 1.32 -> 1
1.53->2
Thanks
There isn't one that I know of, but its easy to write one yourself:
Code:int round(float f)
{
if (int(f-.5)==int(f))
return int(f)+1;
else
return int(f);
}
okay, thx =o)
floor() and ceil() in <math.h>; rather
std::floor() and std::ceil() in <cmath>