TAL Reference Manual
Expressions
TAL Reference Manual—526371-001
4-7
Signed Arithmetic Operators
Table 4-4 shows the combinations of operand types you can use with a binary signed
arithmetic operator and the result type yielded by such operators. In each combination,
the order of the data types is interchangeable.
The compiler treats a STRING or UNSIGNED(1–16) operand as an INT operand. If
bit<0> contains a 0, the operand is positive; if bit <0> contains a 1, the operand is
negative.
The compiler treats an UNSIGNED(17–31) operand as a positive INT(32) operand.
Scaling of FIXED Operands
When you declare a FIXED variable, you can specify an implied fixed-point setting
(
fpoint)—an integer in the range –19 through 19, enclosed in parentheses following the
keyword FIXED. If you do not specify an
fpoint, the default fpoint is 0 (no decimal
places).
Table 4-3. Signed Arithmetic Operators
Operator Operation Operand Type* Example
+ Unary plus Any data type +5
- Unary minus Any data type -5
+ Binary signed addition Any data type alpha+beta
- Binary signed subtraction Any data type alpha-beta
* Binary signed
multiplication
Any data type alpha*beta
/ Binary signed division Any data type alpha/beta
* The data type of the operands must match except as noted in Data Types of Expressions on page 4-2.
Table 4-4. Signed Arithmetic Operand and Result Types
Operand Type Operand Type Result Type Example
STRING STRING INT byte1+byte2
INT INT INT word1-word 2
INT (32) INT (32) INT (32) dbl1 * dbl2
REAL REAL REAL real1 + real2
REAL (64) REAL (64) REAL (64) quad1 + quad2
FIXED FIXED FIXED fixed1 * fixed2
INT STRING INT word1 / byte1
INT Unsigned (1-16) INT word + unsign12
INT (32) Unsigned (17-31) INT (32) double + unsign20
Unsigned (1-16) Unsigned (1-16) INT unsign6 + unsign9
Unsigned (17-31) Unsigned (17-31) INT (32) unsign26 + unsign31