Campbell-scientific CR3000 Micrologger Uživatelský manuál Strana 149

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 590
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 148
Section 7. Installation
149
BeginProg
Fa = 0
Fb = 0.125
L = 126
Ba = Fa 'This will set Ba = False (0)
Bb = Fb 'This will Set Bb = True (-1)
Bc = L 'This will Set Bc = True (-1)
EndProg
FLOAT from LONG or Boolean
When a LONG or Boolean is converted to FLOAT, the integer value is loaded
into the FLOAT. Booleans are converted to -1 or 0. LONG integers greater than
24 bits (16,777,215; the size of the mantissa for a FLOAT) will lose resolution
when converted to FLOAT.
LONG from FLOAT or Boolean
When converted to Long, Boolean is converted to -1 or 0. When a FLOAT is
converted to a LONG, it is truncated. This conversion is the same as the INT
function (Arithmetic Functions
(p. 500) ). The conversion is to an integer equal to or
less than the value of the float (e.g., 4.6 becomes 4, -4.6 becomes -5).
If a FLOAT is greater than the largest allowable LONG (+2,147,483,647), the
integer is set to the maximum. If a FLOAT is less than the smallest allowable
LONG (-2,147,483,648), the integer is set to the minimum.
Integers in Expressions
LONGs are evaluated in expressions as integers when possible. CRBasic example
Evaluation of Integers
(p. 149) illustrates evaluation of integers as LONGs and
FLOATs.
CRBasicExample21. EvaluationofIntegers
Public X, I As Long
BeginProg
I = 126
X = (I+3) * 3.4
'I+3 is evaluated as an integer, then converted to FLOAT before
'it is multiplied by 3.4
EndProg
Constants Conversion
Constants are not declared with a data type, so the CR3000 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, i.e., if the
expression has not yet encountered a FLOAT. CRBasic example Constants to
LONGs or FLOATs
(p. 150) lists a programming case wherein a value normally
considered an integer (10) is assigned by the CR3000 to be As FLOAT.
Zobrazit stránku 148
1 2 ... 144 145 146 147 148 149 150 151 152 153 154 ... 589 590

Komentáře k této Příručce

Žádné komentáře