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
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: ......