Section 7. Installation
Consider the expressions:
x = (z * 1.8) + 32
'(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.
7.8.4.15.1 Floating-Point Arithmetic
Variables and calculations are performed internally in single-precision IEEE four-
byte floating point with some operations calculated in double precision.
Note
Single-precision float has 24 bits of mantissa. Double precision has a 32-bit
extension of the mantissa, resulting in 56 bits of precision. Instructions that use
double precision are
AddPrecise()
,
Average()
,
AvgRun()
,
AvgSpa()
,
CovSpa()
,
MovePrecise()
,
RMSSpa()
,
StdDev()
,
StdDevSpa()
,
Totalize()
, and
TotRun()
.
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 www.wikipedia.org. In summary, CR1000 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
If X = Y then do
.
•
When programming extended-cyclical summation of non-integers, use the
AddPrecise()
instruction. Otherwise, as the size of the sum increases,
fractional addends will have an ever decreasing effect on the magnitude of
the sum, because normal floating-point numbers are limited to about 7 digits
of resolution.
7.8.4.15.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
Read More
Code space can be conserved while filling an array or partial array
with the same value. See an example of how this is done in the CRBasic example
Use of Move() to Conserve Code Space. CRBasic example
Use of Variable
Arrays to Conserve Code Space
(p. 162)
shows example code to convert twenty
temperatures in a variable array from °C to °F.
161
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......