Propeller Manual

Table Of Contents
Operators – Spin Language Reference
The remaining pages of this section further explain each math and logic operator shown in
Table 2-9 in the same order shown.
Constant Assignment ‘
=
The Constant Assignment operator is used only within
CON blocks, to declare compile-time
constants. For example,
CON
_xinfreq = 4096000
WakeUp = %00110000
This code sets the symbol _xinfreq to 4,096,000 and the symbol WakeUp to %00110000.
Throughout the rest of the program the compiler will use these numbers in place of their
respective symbols. See
CON, page 84.
These declarations are constant expressions, so many of the normal operators can be used to
calculate a final constant value at compile time. For example, it may be clearer to rewrite the
above example as follows:
CON
_xinfreq = 4096000
Reset = %00100000
Initialize = %00010000
WakeUp = Reset & Initialize
Here, WakeUp is still set to %00110000 at compile time, but it is now more obvious to future
readers that the
WakeUp symbol contains the binary codes for a Reset and an Initialize
sequence for that particular application.
The above examples create 32-bit signed integer constants; however, it is also possible to
create 32-bit floating-point constants. To do so, the expression must be expressed as a
floating-point value in one of three ways: 1) as an integer value followed by a decimal point
and at least one digit, 2) as an integer with an E followed by an exponent value, or 3) both 1
and 2.
For example:
CON
OneHalf = 0.5
Ratio = 2.0 / 5.0
Miles = 10e5
Page 148 · Propeller Manual v1.1