122-32000 Parallax Inc, 122-32000 Datasheet - Page 143
122-32000
Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Specifications of 122-32000
Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
- Current page: 143 of 438
- Download datasheet (5Mb)
3: Propeller Programming Tutorial
Exercise 12: Whole and Real Numbers
The Propeller is a 32-bit device and can naturally handle whole numbers as signed integers
(-2,147,483,648 to 2,147,483,647) both in constants or in run-time math expressions.
However, for real numbers (those with both integer and fraction components) the compiler
supports floating-point format (single-precision, IEEE-754 compliant) for constants, and
there are library objects that allow for run-time floating-point math operations.
Pseudo-Real Numbers
For handling real numbers, there are many possible techniques. One technique is to use
integer math in a way that accommodates your real values as well as the run-time expressions
involved. We call this pseudo-real numbers.
Having 32-bit integers built in to the Propeller provides us with a lot of “elbow room” for
calculations. For example, perhaps we have an equation to multiply and divide values that
have 2-digit fractions, like the following:
A = B * C / D
For our example, let’s use A = 7.6 * 38.75 / 12.5 which evaluates to 23.56.
To solve this at run time, we can adjust all the equation’s values upward by 2 digits to make
them all integers, perform the math and then treat the rightmost 2 digits of the result as being
the fractional portion. Multiplying each value by 100 achieves this. Here’s the algebraic
proof:
A = (B* 100) * (C * 100) / (D * 100)
A = (7.6 * 100) * (38.75 * 100) / (12.5 * 100)
A = 760 * 3875 / 1250
A = 2356
Since we multiplied all the original values by 100, we know that the final value is really
2356 / 100 = 23.56, but for most purposes we can keep it in integer form knowing that the
rightmost two digits are really to the right of the decimal point.
The above solution works as long as each of the original values and each of the intermediate
results never exceed the signed integer boundaries: -2,147,483,648 to 2,147,483,647.
The example presented next includes code that uses both the pseudo-real number technique as
well as floating-point numbers.
Propeller Manual v1.0 · Page 143
Related parts for 122-32000
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:
GUIDE STUDENT SMART SENSORS
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: