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

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
TRUNC
Remove, “truncate,” the fractional portion from a floating-point constant.
((CON ┆ VAR ┆ OBJ ┆ PUB ┆ PRI ┆ DAT))
Returns: Integer that is the given floating-point constant value truncated at the decimal point.
Explanation
TRUNC
expressions.
expression with the fractional portion removed.
Using TRUNC
TRUNC
The above code creates two floating-point constants,
1.4999, respectively. The next three constants,
are based on
About Floating-Point Constants
The Propeller compiler handles floating-point constants as a single-precision real number as
described by the IEEE-754 standard. Single-precision real numbers are stored in 32 bits, with
a 1-bit sign, an 8-bit exponent, and a 23-bit mantissa (the fractional part). This provides
approximately 7.2 significant decimal digits.
Floating-point constant expressions can be defined and used for many compile-time purposes,
but for run-time floating-point operations, the FloatMath and FloatString objects provide
math functions compatible with single-precision numbers. See the Constant Assignment ‘=’
in the Operators section on page 254,
FloatMath and FloatString objects for more information.
Page 314 · Propeller Manual v1.0
TRUNC
CON
OneHalf = 0.5
Bigger = 1.4999
Int1
Int2
Int3
can be used to retrieve the integer portion of a floating-point constant. For example:
is one of three directives (
FloatConstant
( FloatConstant )
– Spin Language Reference
OneHalf
TRUNC
= trunc(OneHalf)
= trunc(Bigger)
= trunc(Bigger * 10.0) + 4
is the floating-point constant expression to be truncated to an integer.
and
returns an integer constant that is the given floating-point constant
Bigger
using the
FLOAT
FLOAT
,
ROUND
TRUNC
on page 216, and
Int1
and
directive.
,
TRUNC
Int2
OneHalf
and
) used for floating-point constant
Int1
ROUND
Int3
and
= 0,
, are integer constants that
Bigger
on page 303, as well the
Int2
= 1, and
, equal to 0.5 and
Int3
= 18.

Related parts for 122-32000