Specifications
Section 9. CR1000 Programming
9-25
9.13.3.5 Constants Conversion
If a constant (either entered as a number or declared with CONST) can be
expressed correctly as an integer, the compiler will use the type that is most
efficient in each expression. The integer version will be used if possible, i.e., if
the expression has not yet encountered a float. This is illustrated in
EXAMPLE 9.13-4.
EX
AMPLE 9.13-4. CRBASIC Code: Constants to LONGs or FLOATs
Public I AS Long ‘I is an integer
Public F1, F2 ‘F1 and F2 are Floats
CONST ID = 10
BeginProg
I = ID * 5 ‘ID (10) and 5 are loaded at
‘compile time as Floats
F1 = F2 + ID ‘ID (10) is loaded at compile
‘time as a float to avoid a
‘run time conversion from an
‘integer before each addition
EndProg
9.13.4 Logical Expressions
Measurements made by the CR1000 can indicate the absence or presence of
certain conditions. For example, an RH measurement of 100% indicates a
condensation event such as fog, rain, or dew. CR1000’s can render events into
a binary form for further processing, i.e., events can either be TRUE
1
(equal to
-1 in the CR1000)
2
, indicating the condition occurred or is occurring, or
FALSE (0), indicating the condition has not yet occurred or is over.
The CR1000 is able to translate the conditions listed in TABLE 9.13-1 to
bi
nary form (-1 or 0), using the listed instructions and saving the binary form in
the memory location indicated.
1
Several words are commonly interchanged with True / False such as High /
Low, On / Off, Yes / No, Set / Reset, Trigger / Do Not Trigger. The CR1000
understands only True / False or -1 / 0, however. The CR1000 represents
“true” with “-1” because AND / OR operators are the same for logical
statements and binary bitwise comparisons.
2
In the binary number system internal to the CR1000, “-1” is expressed with
all bits equal to 1 (11111111). “0” has all bits equal to 0 (00000000). When -1
is ANDed with any other number, the result is the other number. This ensures
that if the other number is non-zero (true), the result will be non-zero.