|
false negatives
The way that PBASIC "handles" negatives is by treating them as their standard two's complement. -1 is treated as approx. 65,000. Therefore, any useful operation will fail because the number is not actually negative. Because the two's complement system was originally designed to allow "negative" numbers to be added and subtracted using the same CPU instructions as unsigned numbers, these two operations work just fine in PBASIC.
If you need to do negatives for some reason (my team hasn't had any yet), the easiest thing to do is just pretend that something else is zero. For example, you could think of the number 120 as being -7 and the number 134 as being +7. Then, anytime you use this number, just use a Min/Max statement and then subtract 127 off the end, much like the white paper Innovation First has on "One Joystick Tank Drive."
|