122-32000 Parallax Inc, 122-32000 Datasheet - Page 146

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

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
Compile and download RealNumbers.spin. It will display the following on a TV display:
Pseudo-Real Number Result: 2356
Floating-Point Number Result: 23.56
Another Pseudo-Real Number Result: 2356
The pseudo-real results, of course, each represent the value 23.56 but the entire value is
shifted upwards by two digits to maintain integer math compatibility. With some additional
code we could output it as 23.56 for display purposes.
The constants
values are really pseudo-real numbers representing the values in our example equation.
The constants
automatically recognizes them as such and stores them in 32-bit single-precision floating-
point format. They can be used in other compile-time floating-point expressions directly but
at run time they should only be used with floating-point methods such as those found in the
FloatMath and FloatString objects.
The statement
by the Pseudo-Real Numbers technique, above. This is evaluated about 1.6 times faster than
with the floating-point technique and takes much less code space.
The statement
FMul
to divide that result by the floating-point value
FloatString’s
The statement
inside of
digits and truncate the values to integers. The resulting expression is equivalent to that of the
first pseudo-real number equation
its component values to be defined in floating-point terms.
The
compile time. It is required here since floating-point constant values can not be used directly
by run-time expressions.
Page 146 · Propeller Manual v1.0
TRUNC
method to multiply the floating-point values
TRUNC
directive truncates fully resolved floating-point expressions to their integer form at
FloatToString
Term.Dec(iB*iC/iD)
Term.Dec(trunc(B*K)*trunc(C*K)/trunc(D*K))
iB
B
Term.Str(FS.FloatToString(F.FDiv(F.FMul(B, C), D)))
,
directives to shift the floating-point constants
,
C
iC
,
, and
D
, and
iD
method and displays that on the TV.
K
, are floating-point constants (real numbers). The compiler
are standard integer constants as we’ve seen before, but their
Term.Dec(iB*iC/iD)
uses the pre-translated pseudo-real constants as suggested
B
and
D
, translates the result to a string using
C
but has the added benefit of allowing
, then calls FloatMath’s
uses compile-time expressions
B
,
C
, and
D
calls FloatMath’s
upwards by two
FDiv
method

Related parts for 122-32000