Go to Post You win Worlds by innovation. You win Worlds by determination. You win Worlds by engineering a robot so solid, that it successfully completes the game. - Zach O [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Spotlight this post!  
Unread 15-12-2006, 23:23
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Rounding numbers

Quote:
Originally Posted by teh_pwnerer795 View Post
Code:
int i = 1;
static int time_i;

i=i+1; // This will increment 'i' by the value 1 every loop
time_i = ((i * 262) / 10000);
I believe you have declared the wrong variable as static. The way it stands now, i will be set to 1 then incremented to 2 each time through the loop, and time_i will always be computed as 0. If you change it to say
Code:
static int i = 1;
int time_i;
instead, i will remember its value between loops and be incremented as desired, and time_i will do as neilsonster said...

...at least until 125 loops have occurred, after a bit more than 3.25 seconds, after which time (i * 262) will overflow and you'll start getting negative results.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Negative numbers? Calvin Programming 6 09-02-2005 10:46
Part Numbers DDRAngelKurumi Kit & Additional Hardware 1 29-01-2005 18:38
Random Numbers Astronouth7303 Programming 9 18-01-2004 21:39
Team Numbers archiver 2000 2 24-06-2002 00:24
Numbers at VCU Madison Regional Competitions 5 10-03-2002 02:26


All times are GMT -5. The time now is 01:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi