122-28029 Parallax Inc, 122-28029 Datasheet - Page 157
122-28029
Manufacturer Part Number
122-28029
Description
GUIDE STUDENT SMART SENSORS
Manufacturer
Parallax Inc
Datasheet
1.122-28029.pdf
(340 pages)
Specifications of 122-28029
Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Smart Sensors
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
- Current page: 157 of 340
- Download datasheet (5Mb)
Example Program: TestCompassAveraged.bs2
PBASIC Division with Negative Numbers
The PBASIC division and modulus (/ and //) operators are for use with positive numbers. If
the numerator might be negative, the best approach is to save the numerator's sign before
taking its absolute value (sign = numerator.BIT15).
operation. Optionally, you can also round up or down depending on the remainder of the
division. Before you're done, check the sign, and if it's negative, make the result negative
(result = - result).
Free Download This program is available as a free .bs2 file download from the Smart
Sensors and Applications Product Page at www.parallax.com.
' Divide xSum
sign = xSum.BIT15
xSum = ABS(xSum)
x = xSum / 10
IF xSum // 10 >=5 THEN x = x + 1
IF sign = Negative THEN x = - x
sign = ySum.BIT15
ySum = ABS(ySum)
y = ySum / 10
IF ySum // 10 >=5 THEN y = y + 1
IF sign = Negative THEN y = - y
RETURN
numerator VAR Word
denominator VAR Word
result VAR Word
sign VAR Bit
Negative CON 1
Positive CON 0
' Division routine with a numerator that might be negative.
sign = numerator.BIT15
numerator = ABS(numerator)
result = numerator / denominator
IF numerator // denominator >= (denominator / 2) THEN
ENDIF
IF sign = Negative THEN result = - result
result = result + 1
Chapter 4: Hitachi HM55B Compass Module · Page 145
' Store sign of xSum
' Take absolute value
' x = the average measurement
' Fraction > .5? Round up
' if xSum negative, negate x
' Store sign of ySum
' Take absolute value
' y = the average measurement
' Fraction > .5? Round up
' if ySum negative, negate y
Then, perform the division
Related parts for 122-28029
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
Part Number:
Description:
MANUAL FOR SUMOBOT
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
GUIDE STUDENT PROCESS CONTROL
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
MANUAL PROPELLER
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
LEAD WIRES FLYING CABLE III/IV
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
BOARD ADAPTER AND FLY LEADS
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
PLATFORM CABLE USB II
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
KIT STARTER COOLRUNNER-II BUNDLE
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
Microcontroller Modules & Accessories DISCONTINUED BY PARALLAX
Manufacturer:
Parallax Inc
Part Number:
Description:
Microcontroller Modules & Accessories DISCONTINUED BY PARALLAX
Manufacturer:
Parallax Inc
Part Number:
Description:
BOOK UNDERSTANDING SIGNALS
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
BOARD EXPERIMENT+LCD NX-1000
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
IC MCU 2K FLASH 50MHZ SO-18
Manufacturer:
Parallax Inc
Datasheet: