Section 7. Installation
converted to a
LONG
, it is truncated. This conversion is the same as the
INT
function (
Arithmetic Functions
(p. 568)
). The conversion is to an integer equal to or
less than the value of the float; for example,
4.6
becomes
4
and –
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
LONG
s are evaluated in expressions as integers when possible. CRBasic example
Evaluation of Integers
(p. 163)
illustrates evaluation of integers as
LONG
s and
FLOAT
s.
CRBasic Example 19.
Evaluation of Integers
'This program example demonstrates the evaluation of integers.
Public
I
As Long
Public
X
As Float
BeginProg
I = 126
X = (I+3) * 3.4
'I+3 is evaluated as an integer, then converted to Float data type before it is
'multiplied by 3.4.
EndProg
Constants Conversion
Constants are not declared with a data type, so the CR1000 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, for example, if
the expression has not yet encountered a
FLOAT
. CRBasic example
Constants to
LONGs or FLOATs
(p. 163)
lists a programming case wherein a value normally
considered an integer (10) is assigned by the CR1000 to be
As FLOAT
.
CRBasic Example 20.
Constants to LONGs or FLOATs
'This program example demonstrates conversion of constants to Long or Float data types.
Public
L
As Long
Public
F1
As Float
Public
F2
As Float
Const
ID = 10
BeginProg
F1 = F2 + ID
L = ID * 5
EndProg
In CRBasic example
Constants to LONGs or FLOATs
(p. 163),
I
is an integer.
A1
and
A2
are
FLOATS
. The number 5 is loaded
As FLOAT
to add efficiently with
constant ID, which was compiled
As FLOAT
for the previous expression to avoid
an inefficient runtime conversion from
LONG
to
FLOAT
before each floating
point addition.
163
Содержание CR1000
Страница 2: ......
Страница 4: ......
Страница 6: ......
Страница 32: ......
Страница 36: ......
Страница 38: ......
Страница 40: ......
Страница 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Страница 96: ......
Страница 98: ...98 ...
Страница 302: ......
Страница 350: ...Section 8 Operation Figure 91 Pulse Sensor Output Signal Types Figure 92 Switch Closure Pulse Sensor 350 ...
Страница 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Страница 454: ...Section 8 Operation 8 8 1 Data Display Figure 116 Displaying Data with the Keyboard Display 454 ...
Страница 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Страница 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Страница 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Страница 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Страница 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Страница 478: ......
Страница 506: ......
Страница 536: ......
Страница 636: ......
Страница 642: ......
Страница 644: ......
Страница 676: ......
Страница 677: ......