Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 231
2
BS2 Runtime Math and Logic
The BS2, like any computer, excels at math and logic. However, being
designed for control applications, the BS2 does math a little differently
than a calculator or spreadsheet program. This section will help you
understand BS2 numbers, math, and logic.
Number Representations
In your programs, you may express a number in various ways, de-
pending on how the number will be used and what makes sense to
you. By default, the BS2 recognizes numbers like 0, 99 or 62145 as be-
ing in our everyday decimal (base-10) system. However, you may also
use hexadecimal (base-16; also called hex) or binary (base-2).
Since the symbols used in decimal, hex and binary numbers overlap
(e.g., 1 and 0 are used by all; 0 through 9 apply to both decimal and hex)
the Stamp software needs prefixes to tell the numbering systems apart:
99 Decimal (no prefix)
$1A6 Hex
%1101 Binary
The Stamp also automatically converts quoted text into ASCII codes,
and allows you to apply names (symbols) to constants from any of the
numbering systems. Examples:
letterA con "A" ' ASCII code for A (65).
cheers con 3
hex128 con $80
fewBits con %1101
For more information on constants, see the section BS2 Constants and
Compile-Time Expressions.
When is Runtime?
Not all of the math or logic operations in a BS2 program are solved by
the BS2. Operations that define constants are solved by the Stamp host
software before the program is downloaded to the BS2. This prepro-
cessing before the program is downloaded is referred to as “compile
time.” (See the section BS2 Constants and Compile-Time Expressions.)










