View Single Post
  #3   Spotlight this post!  
Unread 08-02-2005, 22:11
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,112
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: Negative numbers?

The joystick inputs are of type unsigned char. Trying to do arithmetic with them that yields negative results (e.g. p1_x - 127 when p1_x is less than 127) is just asking for things to blow up.

I get around the problem by reading the joystick input values into a temporary int first, and do all the computations with that.