View Single Post
  #3   Spotlight this post!  
Unread 08-12-2006, 00:29
theycallhimtom theycallhimtom is offline
Registered User
AKA: Tom Conerly
FRC #1540 (The Flaming Chickens)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Lake Oswego, Oregon
Posts: 52
theycallhimtom has a spectacular aura abouttheycallhimtom has a spectacular aura abouttheycallhimtom has a spectacular aura about
Send a message via AIM to theycallhimtom Send a message via MSN to theycallhimtom
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...