EasyManua.ls Logo

Campbell CR800 Series - Constants to Longs or Floats; Evaluation of Integers; Logical Expressions

Campbell CR800 Series
598 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Section 7. Installation
163
Evaluation of Integers
'This program example demonstrates the evaluation of integers.
Public I As Long
Public X As Float
BeginProg
I = 126
X = (I+3) * 3.4
'I+3 is evaluated as an integer, then converted to Float data type before it is
'multiplied by 3.4.
EndProg
Constants Conversion
Constants are not declared with a data type, so the CR800 assigns the data type as
needed. 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 is used if possible, for example, if
the expression has not yet encountered a FLOAT. CRBasic example Constants to
LONGs or FLOATs
(p. 163) lists a programming case wherein a value normally
considered an integer (10) is assigned by the CR800 to be As FLOAT.
Constants to LONGs or FLOATs
'This program example demonstrates conversion of constants to Long or Float data types.
Public L As Long
Public F1 As Float
Public F2 As Float
Const ID = 10
BeginProg
F1 = F2 + ID
L = ID * 5
EndProg
In the just previous CRBasic example, L is an integer. F1 and F2 are FLOATS.
The numeral 5 is loaded As FLOAT to add efficiently with constant ID, which
was compiled As FLOAT for the previous expression to avoid an inefficient
runtime conversion from LONG to FLOAT before each floating point addition.
7.6.3.16.4 Logical Expressions
Measurements can indicate absence or presence of an event. For example, an RH
measurement of 100% indicates a condensation event such as fog, rain, or dew.
The CR800 can render the state of the event into binary form for further
processing, so the event is either occurring (true), or the event has not occurred
(false).
True = -1, False = 0
In all cases, the argument 0 is translated as FALSE in logical expressions; by
extension, any non-zero number is considered "non-FALSE." However, the

Table of Contents

Related product manuals