BASIC stamp manual v2.2

DEBUG – BASIC Stamp Command Reference
Page 164 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
hexadecimal, you might think it was 41, in decimal… a totally different
number. To help avoid this, use the IHEX formatter (the "I" stands for
indicated). Changing the DEBUG line to read: DEBUG IHEX x would
print "$41" on the screen. A similar formatter for binary also exists, IBIN,
which prints a "%" before the number.
Signed numbers are preceded with a space ( ) or a minus sign (-) to
indicate a positive or negative number, respectively. Normally, any
number displayed by the BASIC Stamp is shown in its unsigned (positive)
form without any indicator. The signed formatters allow you to display
the number as a signed (rather than unsigned) value. NOTE: Only Word-
sized variables can be used for signed number display. The code below
demonstrates the difference in all three numbering schemes.
x VAR Word
x = -65
DEBUG "Signed: ", SDEC x, " ", ISHEX x, " ", ISBIN x, CR
DEBUG "Unsigned: ", DEC x, " ", IHEX x, " ", IBIN x
This code will generate the display shown below:
Signed: -65 -$41 -%1000001
Unsigned: 65471 $FFBF %1111111110111111
The signed form of the number –65 is shown in decimal, hexadecimal and
then in binary on the top line. The unsigned form, in all three number
systems, is shown on the bottom line. If the unsigned form looks strange
to you, it's because negative numbers are stored in twos complement
format within the BASIC Stamp.
Suppose that your program contained several DEBUG instructions
showing the contents of different variables. You would want some way to
tell them apart. One possible way is to do the following:
x VAR Byte
y VAR Byte
x = 100
y = 250
DEBUG "X = ", DEC x, CR ' Show decimal value of x
DEBUG "Y = ", DEC y, CR ' Show decimal value of y
DISPLAYING SIGNED VS. UNSIGNED
NUMBERS
.
A
UTOMATIC NAMES IN THE DISPLAY.