Campbell-scientific CR9000X Measurement and Control System Uživatelský manuál Strana 164

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 442
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 163
Section 4. CRBasic – Native Language Programming
4.2.11.3 Expressions with Numeric Data Types
FLOATs, LONGs and Booleans are cross-converted to other data types, such as
FP2, by using “=”
4.2.11.3.1 Boolean from FLOAT or LONG
When a FLOAT or LONG is converted to a Boolean as shown in EXAMPLE
4.0-2, zero becomes False (0) and non-zero becomes True (-1).
EXAMPLE 4.0-2. CRBASIC Code: Conversion of FLOAT / LONG to
Boolean
Public Fa AS FLOAT, Fb AS FLOAT, L AS LONG
Public Ba AS Boolean, Bb AS Boolean, Bc AS Boolean
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
4.2.11.3.2 FLOAT from LONG or Boolean
When a LONG or Boolean is converted to FLOAT, the integer value is loaded
into the FLOAT. Booleans will be converted to -1 or 0 depending on whether
the value is non-zero or zero. LONG integers greater than 24 bits (16,777,215;
the size of the mantissa for a FLOAT) will lose resolution when converted to
FLOAT.
4.2.11.3.3 LONG from FLOAT or Boolean
Booleans will be 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. 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.
4.2.11.3.4 Integers in Expressions
LONGs are evaluated in expressions as integers when possible. Example
4.2.11-3 illustrates evaluation of integers as LONGs and FLOATs.
4-36
Zobrazit stránku 163
1 2 ... 159 160 161 162 163 164 165 166 167 168 169 ... 441 442

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

Žádné komentáře