pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Table 25 Arithmetic Expressions (continued)
ExampleSyntax
2 * 3 + var / 2expression operand expression
2 * var * 4expression operand expression
A condition code cannot appear inside an arithmetic expression; for example, the following is not
valid in pTAL:
a := <; !Illegal
Signed Arithmetic Operators
Table 26 Signed Arithmetic Operators
ExampleOperand Type*OperationOperator
+5Any data typeUnary plus+
-5Any data typeUnary minus-
alpha + betaAny data typeBinary signed addition+
alpha - betaAny data typeBinary signed subtraction-
alpha * betaAny data typeBinary signed multiplication*
alpha / betaAny data typeBinary signed division/
* The data type of the operands must match, except as noted in Data Types of Expressions (page 70).
In Table 27 (page 73), the order of the data types is interchangeable.
Table 27 Signed Arithmetic Operand and Result Types
ExampleResult TypeOperand TypeOperand Type
byte1 + byte2INTSTRINGSTRING
word1 - word2INTINTINT
dbl1 * dbl2INT(32)INT(32)INT(32)
real1 + real2REALREALREAL
quad1 + quad2REAL(64)REAL(64)REAL(64)
fixed1 * fixed2FIXEDFIXEDFIXED
word1 / byte1INTSTRINGINT
word + unsign12INTUNSIGNED(1-16)INT
double + unsign20INT(32)UNSIGNED(17-31)INT(32)
unsign6 + unsign9INTUNSIGNED(1-16)UNSIGNED(1-16)
unsign26 + unsign31INT(32)UNSIGNED(17-31)UNSIGNED(17-31)
The compiler treats a STRING or UNSIGNED(1-16) operand as an INT operand. If bit <0> contains
0, the operand is positive; if bit <0> contains 1, the operand is negative. For more information,
see Data Types of Expressions (page 70).
The compiler treats an UNSIGNED(17-31) operand as a positive INT(32) operand.
Signed arithmetic operators affect the hardware indicators as described in Chapter 13 (page 234).
Signed Arithmetic Operators 73