Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 271
2
redirected the program to the label after Then, “isLess.” If you change
“aNumber = 99” to “aNumber = 100” the other message, “greater than
or equal to 100,” will appear instead. The condition “aNumber < 100”
is false if aNumber contains 100 or more. The values compared in the
If...Then condition can also be expressions:
Number1 var byte
Number2 var byte
Number1 = 99
Number2 = 30
IF Number1 = Number2 * 4 - 20 THEN equal
debug "not equal"
stop
equal:
debug "equal"
stop
Since Number2 * 4 - 20 = (30 x 4) - 20 = 100, the message “not equal”
appears on the screen, Changing that expression to Number2 * 4 - 21
would get the “equal” message.
Beware of mixing signed and unsigned numbers in If...Then compari-
sons. Watch what happens when we change our original example to
include a signed number (–99):
IF -99 < 100 THEN isLess
debug "greater than or equal to 100"
stop
isLess:
debug "less than 100"
stop
Although –99 is obviously less than 100, the program says it is greater.
The problem is that –99 is internally represented as the two’s comple-
ment value 65437, which (using unsigned math) is greater than 100.
Don’t mix signed and unsigned values in If...Then comparisons.
Logic Operators
If...Then supports the logical operators NOT, AND, OR, and XOR. NOT
inverts the outcome of a condition, changing false to true, and true to










