Go to Post Does IR work underwater? Or more importantly, through an air-water interface? ... sigh ... - Rich Kressly [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
  #4   Spotlight this post!  
Unread 25-02-2007, 21:12
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Trouble with Autonomous

Quote:
Originally Posted by Joe Ross View Post
Since you don't really care what order the operations happen, the following will work for you.

time = (1000 * degrees) / 300;
time = (1000 * 30) / 300;
time = (30000) / 300;
time = 100;

The only problem with the above example is that if degrees gets above 32, you'd overflow the integer value. You could either declare time as a long, or change your constants, since multiplying by 1000 then dividing by 300 is the same as multiplying by 10 then dividing by 3.
If he doesn't want to declare time as a long and carry that through the rest of the calculations, the following will work with time left as an int.

time = (int) ((long) 1000 * degrees / 300);

or more simply if the compiler is really ANSI compliant

time = (int) (1000L * degrees / 300);
 


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
Trouble with the GTS Bomberofdoom Programming 1 04-02-2007 10:13
Has anyone else had trouble staying within the 10 second limit in autonomous? lkdjm Programming 18 12-02-2006 18:10
Autonomous Code trouble The yellowdart Programming 16 21-01-2006 10:36
My trouble with fund raising. BaldwinNYRookie Fundraising 5 03-04-2005 13:34
Trouble with pwm outputs misterikkit Programming 16 17-01-2004 10:56


All times are GMT -5. The time now is 19:24.

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