28029 Parallax Inc, 28029 Datasheet - Page 92

KIT PARTS SMART SENSORS W/TEXT

28029

Manufacturer Part Number
28029
Description
KIT PARTS SMART SENSORS W/TEXT
Manufacturer
Parallax Inc
Datasheet

Specifications of 28029

Accessory Type
Parts Kit
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
BASIC Stamp® or Javelin Modules
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Other names
28029PAR
Page 80 · Smart Sensors and Applications
Your Turn - PBASIC and Negative Numbers
The last example program used the
as a signed number.
unsigned value in the range from 0 to 65535 or a signed value from −32768 to +32767.
That’s because it uses the two’s complement method for signed numbers. In this system,
all positive numbers, in binary, begin with a 0 and all negative numbers, in binary, begin
with a 1. Using two’s complement, the values 0 to 32767 are represented by their normal
16-bit binary equivalents, but −1 to −32768 are not. Instead, those negative numbers are
represented by the binary equivalents of 32768 to 65535.
Picture a number line, as in Figure 3-12 . From 0 forward, the values 0 to 32767 are
represented by their normal 16-bit binary equivalents: the value 1 is represented by
binary 1, and so on, up to 32767. But −1 is represented by the binary equivalent of
65535, the largest word-sized value, which is all 1’s. Going backwards along the negative
values, the representative binary numbers get smaller until −32768 is represented by
binary 32768.
Test various other values that range from 1875 to 3125, and verify with a
calculator that the output value’s position in the output range is proportional to
the input value’s position in the input range.
Unsigned
Decimal
32767
32768
65535
1
Table 3-1:
Remember that in PBASIC a word-sized variable can hold an
0000000000000001
0111111111111111
1000000000000000
1111111111111111
Bit 15
Two’s Complement Signed Decimal
and Binary Numbers
DEBUG SDEC
16-Bit Binary
modifier to display the
Bit 0
Decimal
Signed
-32768
32767
-1
1
value
variable

Related parts for 28029