View Single Post
  #12   Spotlight this post!  
Unread 02-02-2003, 14:34
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Quote:
Originally posted by n[ate]vw
Let's say stack_pos=1 and sw_stacker=100

if stack_pos - sw_stacker > 10 then pos_error

Will this go to pos_error or not?
1-100= -99, which to the controller might be -99 or 157, depending on how it handles negative numbers in this situation.
why dont you just take a page out of innovationfirst's book and their basic programming to avoid negatives. try something like this:

if (((stack_pos + 100 - sw_stacker) Min 100) - 100) > 10 then {whatever}

anything that would be a negative number is instead turned into a zero, and all this code is looking at is whether it is less than 10 or not, not by how much it is less than ten.

-Anthony

P.S. i dont know the range of your values, so iff 100 is too little or too much, you can change it accordingly
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year