CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Section 9. Programming<br />
Read More! More information is available in CRBASIC Editor Help topic<br />
"Multipliers and Offsets with Repetitions".<br />
9.10 Expressions<br />
An expression is a series of words, operators, or numbers that produce a value<br />
or result. Expressions are evaluated expression from left to right, with deference<br />
to precedence rules.<br />
Two types of expressions, mathematical and programming, are used in<br />
CRBASIC. A useful property of expressions in CRBASIC is that they are<br />
equivalent to and often interchangeable with their results.<br />
Consider the expressions:<br />
x = (z * 1.8) + 32 (a mathematical expression)<br />
If x = 23 then y = 5 (programming expression)<br />
The variable x can be omitted and the expressions combined and written as:<br />
If (z * 1.8 + 32 = 23) then y = 5<br />
Replacing the result with the expression should be done judiciously and with the<br />
realization that doing so may make program code more difficult to decipher.<br />
9.10.1 Floating Point Arithmetic<br />
Variables and calculations are performed internally in single precision IEEE4 4-<br />
byte floating point, a binary format.<br />
Floating point arithmetic is common in many electronic computational systems,<br />
but it has pitfalls high-level programmers should be aware of. Several sources<br />
discuss floating point arithmetic thoroughly. One readily available source is the<br />
topic "Floating Point" at Wikipedia.org. In summary, <strong>CR200</strong>(X) programmers<br />
should consider at least the following:<br />
• Floating point numbers do not perfectly mimic real numbers.<br />
• Floating point arithmetic does not perfectly mimic true arithmetic.<br />
• Avoid use of equality in conditional statements. Use >= and