View Single Post
  #10   Spotlight this post!  
Unread 14-02-2004, 15:34
Meandmyself's Avatar
Meandmyself Meandmyself is offline
Registered Magic Programming User
AKA: Gordon
#1123 (AIM robotics Crimson Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: springfield, VA
Posts: 26
Meandmyself will become famous soon enough
Re: printf isn't printf-ing. Help!

Quote:
Originally Posted by Mark McLeod
current.theta += (unsigned long) ((gyroin + gyroprev - 1023) * deltat * 8 / 100) + 2000;
OK, so if Current.theta is an unsigned int, and I'm setting it equal to an unsigned long, what bits will I lose in the process? the most significant 8?
for example, what if I had this:
Code:
unsigned long longvar = 0xFAAABBBB;
unsigned int shortvar = 0;
shortvar = longvar;
shortvar would be 0xBBBB, right?

and a second question about that, am I getting an overflow error because the pic does math on an int level, and when an operation goes higher than an int I get an overflow error?

Thanks for all your help so far.
__________________
They call me the Idea man.
Not because my ideas work,
But because I have ideas...


I'm not a programmer. I'm an electrical guy who can program. If only I understood C!

www.aim-robotics.org //team website
www.tjhsst.edu/~gburgett //cool stuff for school