BASIC stamp manual v2.2
4: BASIC Stamp Architecture – +
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 109
doing its integer-only math. So it computes the square root of 100 as 10
(correct), but the square root of 99 as 9 (the actual is close to 9.95).
Example:
DEBUG ? SQR 100 ' Display square root of 100 (10)
DEBUG ? SQR 99 ' Display of square root of 99
' ...(9 due to truncation)
Table 4.6 lists the available Binary (two-argument) Operators.
Table 4.6: Binary Operators. Note:
some binary operators are not
supported by all BASIC Stamp
models.
Operator Description Supported By:
+ Addition All
- Subtraction All
* Multiplication All
** Multiplication (returns upper 16-bits) All
*/ Multiply by 8-bit integer, 8-bit fraction All BS2 models
/ Division All
// Modulus (Remainder of division) All
ATN Returns arctangent of X/Y vector All BS2 models
HYP Returns hypotenuse of X/Y vector All BS2 models
MIN Limits a value to a specified low All
MAX Limits a value to a specified high All
DIG Returns specified digit of number All BS2 models
<< Shift bits left by specified amount All BS2 models
>> Shift bits right by specified amount All BS2 models
REV Reverse specified number of bits All BS2 models
& Bitwise AND All
| Bitwise OR All
^ Bitwise XOR All
&/ Logical AND NOT BS1 Only
|/ Logical OR NOT BS1 Only
^/ Logical XOR NOT BS1 Only
The Addition operator (+) adds 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 of addition is larger than 65535, the carry bit
will be lost. If the values added are signed 16-bit numbers and the
destination is a 16-bit variable, the result of the addition will be correct in
both sign and value.
ADD: +
B
INARY OPERATORS.
1
A
ll
2