Number Representations - Parallax BASIC Stamp 2e Programming Manual

Table of Contents

Advertisement

4: BASIC Stamp Architecture – Number Representations
R
M
L
.
UNTIME
ATH AND
OGIC
2
1
2
e
N
R
UMBER
EPRESENTATIONS
2
2
e
The BASIC Stamp, like any computer, excels at math and logic. However,
being designed for control applications, the BASIC Stamp does math a
2
2
little differently than a calculator or spreadsheet program. This section will
sx
p
help you understand BASIC Stamp numbers, math, and logic.
In your programs, you may express a number in various ways, depending
.
on how the number will be used and what makes sense to you. By default,
the BASIC Stamp recognizes numbers like 0, 99 or 62145 as being 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
editor software needs prefixes to tell the numbering systems apart, as
shown below:
99
Decimal (no prefix)
$1A6
Hex
%1101
Binary
The BASIC Stamp also automatically converts quoted text into ASCII
codes, and allows you to apply names (symbols) to constants from any of
the numbering systems. For example:
1
SYMBOL
LetterA
SYMBOL
Cheers
SYMBOL
Hex128
SYMBOL
FewBits
-- or --
2
2
LetterA
CON
sx
p
Cheers
CON
Hex128
CON
FewBits
CON
For more information on constants, see the section "Constants and
Compile-Time Expressions", above.
=
"A"
=
3
=
$80
=
%1101
"A"
' ASCII code for A (65).
3
$80
%1101
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 59
' ASCII code for A (65).

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents