![background image](http://html1.mh-extra.com/html/campbell/cr200/cr200_instruction-manual_489088097.webp)
Section 9. Programming
87
Read More!
More information is available in CRBASIC Editor Help topic
"Multipliers and Offsets with Repetitions".
9.10 Expressions
An expression is a series of words, operators, or numbers that produce a value
or result. Expressions are evaluated expression from left to right, with deference
to precedence rules.
Two types of expressions, mathematical and programming, are used in
CRBASIC. A useful property of expressions in CRBASIC is that they are
equivalent to and often interchangeable with their results.
Consider the expressions:
x = (z * 1.8) + 32 (a mathematical expression)
If x = 23 then y = 5 (programming expression)
The variable x can be omitted and the expressions combined and written as:
If (z * 1.8 + 32 = 23) then y = 5
Replacing the result with the expression should be done judiciously and with the
realization that doing so may make program code more difficult to decipher.
9.10.1 Floating Point Arithmetic
Variables and calculations are performed internally in single precision IEEE4 4-
byte floating point, a binary format.
Floating point arithmetic is common in many electronic computational systems,
but it has pitfalls high-level programmers should be aware of. Several sources
discuss floating point arithmetic thoroughly. One readily available source is the
topic "Floating Point" at Wikipedia.org. In summary, CR200(X) programmers
should consider at least the following:
•
Floating point numbers do not perfectly mimic real numbers.
•
Floating point arithmetic does not perfectly mimic true arithmetic.
•
Avoid use of equality in conditional statements. Use >= and <= instead. For
example, use "If X => Y, then do" rather than using, "If X = Y, then do".
9.10.2 Mathematical Operations
Mathematical operations are written out much as they are algebraically. For
example, to convert Celsius temperature to Fahrenheit, the syntax is:
TempF = TempC * 1.8 + 32
Содержание CR200
Страница 32: ...Section 2 Quickstart Tutorial 22 ...
Страница 45: ...Section 3 Overview 35 3 3 Specifications ...
Страница 46: ...Section 3 Overview 36 ...
Страница 58: ...Section 4 Sensor Support 48 ...
Страница 62: ...Section 5 Measurement and Control Peripherals 52 ...
Страница 78: ...Section 8 CR200 X Configuration 68 ...
Страница 102: ...Section 9 Programming 92 ...
Страница 138: ...Section 11 Programming Resource Library 128 ...
Страница 156: ...Section 16 Support Software 146 ...
Страница 160: ...Section 17 Care and Maintenance 150 ...
Страница 166: ...Section 18 Troubleshooting 156 18 3 3 Diagnosis and Fix Procedures 18 3 3 1 Battery Voltage Test ...
Страница 167: ...Section 18 Troubleshooting 157 18 3 3 2 Charging Circuit Test Solar Panel ...
Страница 168: ...Section 18 Troubleshooting 158 18 3 3 3 Charging Circuit Test Transformer ...
Страница 169: ...Section 18 Troubleshooting 159 18 3 3 4 Adjusting Charging Circuit Voltage ...
Страница 170: ...Section 18 Troubleshooting 160 ...
Страница 184: ...Appendix A Glossary 14 ...
Страница 190: ...Appendix B Status Table and Settings 20 ...
Страница 192: ...Appendix C Serial Port Pin Outs 22 ...
Страница 211: ......