BASIC stamp manual v2.2
BASIC Stamp Architecture – +, -, *
Page 110 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
For example:
SYMBOL value1 = W0
SYMBOL value2 = W1
value1 = - 99
value2 = 100
value1 = value1 + value2 ' Add the numbers
DEBUG value1 ' Show the result (1)
-- or --
value1 VAR Word
value2 VAR Word
value1 = - 1575
value2 = 976
value1 = value1 + value2 ' Add the numbers
DEBUG SDEC ? value1 ' Show the result (-599)
The Subtraction operator (-) subtracts variables and/or constants,
returning a 16-bit result. It works exactly as you would expect with
unsigned integers from 0 to 65535. If the result is negative, it will be
correctly expressed as a signed 16-bit number. For example:
SYMBOL value1 = W0
SYMBOL value2 = W1
value1 = 199
value2 = 100
value1 = value1 - value2 ' Subtract the numbers
DEBUG value1 ' Show the result (99)
-- or --
value1 VAR Word
value2 VAR Word
value1 = 1000
value2 = 1999
value1 = value1 - value2 ' Subtract the numbers
DEBUG SDEC ? value1 ' Show the result (-999)
The Multiply operator (*) multiplies variables and/or constants, returning
the low 16 bits of the result. It works exactly as you would expect with
unsigned integers from 0 to 65535. If the result of multiplication is larger
than 65535, the excess bits will be lost. Multiplication of signed variables
will be correct in both number and sign, provided that the result is in the
range -32767 to +32767.
SUBTRACT: -
M
ULTIPLY: *
1
All
2
1
All
2
1
A
ll
2
1
A
ll
2