
15-12-2006, 19:57
|
|
Registered User
AKA: !!Mitch!!
 FRC #1392
Team Role: Programmer
|
|
Join Date: Nov 2006
Rookie Year: 2006
Location: Ajax, Canada
Posts: 142
|
|
|
Re: Rounding numbers
Quote:
Originally Posted by neilsonster
Ohh I see. Actually, this line:
Code:
time_i = ((i * 262) / 10000);
performs integer division, since time_i is an integer (you declared it as one). If you had declared time_i as a float/double, then this would give you a floating point number.
So after that line above, time_i is assigned 0 until i > 38 (i*262/10000 = i*0.0262 < 1, but since we have an integer it truncates the decimal part and gives you 0). For 38 <= i <= 76, time_i will be assigned 1 (you will have 1.***, and the decimal part will be removed). For 77 <= i <= 152, time_i = 2, and so on.
|
Awesome thanxs alot .. makes more sense now 
__________________
Great Art is Created; Master Pieces are Stolen
[n00b]Teh_Foxdonut teh_pwnerer795 - CounterStrike:Source
|