View Single Post
  #1   Spotlight this post!  
Unread 09-01-2008, 01:52
JohnC's Avatar
JohnC JohnC is offline
my other name is nigel
FRC #0360 (360 Revolution)
Team Role: Programmer
 
Join Date: Mar 2005
Rookie Year: 2005
Location: user_routines.c
Posts: 100
JohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the rough
Send a message via AIM to JohnC
Re: How does division work?

If you add 0.5, it will "round" to the nearest integer:

int x = (int)(40/9 + 0.5); // 40/9 = 4.444 repeating and rounds down to 4

int y = (int)(40/6 + 0.5); // 40/6 = 6.666 repeating, rounds up to 7
__________________
What place are we at? ... TODAI!