View Single Post
  #10   Spotlight this post!  
Unread 27-02-2007, 15:39
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 popnbrown View Post
Well I decided to take advice. And:

Code:
 long time = (1000 * degrees) / 300;
Yet When I call it as:

Code:
Rotate(-1, 30, 10);
and still time = 0;. This is really getting to me as we have two days till regional. Any1 know what is going on?
One problem but it's probably not your error is that making time long will not force the calculation on the right of the = to be done as long. C only looks at the participants in the equation to decide how to do the arithmetic, not what you're assigning the result to. So again, you need to cast one of one of the leading values on the right side as (long) or use 1000L. C will call 1000 an int and 1000L is a long.

How are you displaying time to know it's zero? Are you still using the %d specifier in your printf? I can't remember if the PICs are little endian or big endian. If they're big endian, you'll only see the high order half of the long value which in this case is zero.