|
Re: Rounding numbers
Usually when I want to round I just use some integer math. It can be kind of ugly but most of the times it works well and I do not have to memorize function calls. When you convert a floating point number to an int it will always round down so if you add .5 to a float then convert to an integer it will be rounded correctly.
float num = 1.5f;
int rounded = (int)(num+.5)
But anyway using a round function is probably better style...
|