UD70
Issue code: 70nu2
DPL programming
4-3
4.3 Variables
Basic variables
There are two basic types of variable, as follows:
•
Integer variable (
INT
)
•
Floating-point variable (
FLOAT
)
Integer
variables
Integer variables are denoted by placing a %
% symbol after the name of the
variable, and are internally represented by a two’s complement
32-bit number. This gives a decimal range of
±
2147483647.
Floating-
point
variables
Floating-point variables have no symbol. These variables are
IEEE double-precision (64-bit) numbers which give a range of approximately
±
1.7976 x 10
±
308
.
Accessing the variables
All variables are global within a program (ie. they can be accessed and
altered by any task). (There are no local variables.)
Bit-addressing of variables
All integer variables and arrays (see below) may be bit-addressed. This
means that each individual binary bit in the variable may be separately read
or written to. Bit-addressing is achieved by appending .n
.n to the end of the
variable name, where n
n is the bit number to be accessed.
Example
flags%.3 = 1
;set bit 3 to 1
IF flags%.5 = 1 THEN ...
;check bit 5
Naming conventions
The first character of a variable must be a letter. Subsequent characters
may include letters, numbers and the underscore (
_
) character. These may
be in any order.
Variable names are case sensitive (eg. the variable name speed%
speed% is not the
same as SPEED%
SPEED%).
Preferred use of variables
It is recommended that integer variables are used where possible.
Operations on integer variables perform much faster than for
floating-point variables.
Summary of Contents for UD70
Page 6: ......
Page 14: ...UD70 Issue code 70nu2 2 6 Installation...
Page 42: ...UD70 Issue code 70nu2 4 20 DPL programming...
Page 98: ...UD70 Issue code 70nu2 7 22 Reference...