SPL to HP C/XL Migration Guide (30231-90001)

5-17
|||
|
sign
: | Same as SPL, except: |
|||
|+ |
(
+
is not permitted as a sign)
|
|- | |
|||
---------------------------------------------------------------------------------------------
|||
|
operator
: | Same as SPL, except: |
|||
|+
(addition)
||
|-
(subtraction)
||
|*
(multiplication)
||
|/
(division)
||
|^
(exponentiation allows real and long
|
Convert
^
to
pow(
x
,
y
)
function.
|
|
values to integer power)
||
| MOD
(modulus)
|%
(modulus)
|
|||
| Note: The SPL exponentiation operator, | |
| "^", is the HP C/XL exclusive OR operator. | |
|||
---------------------------------------------------------------------------------------------
|||
|
primary
: | Same as SPL, except: |
|||
|
variable
||
|
constant
||
|
bit-operation
||
|(
arithmetic-expression
)| |
|\
arithmetic-expression
\|
Convert
\
...
\
to
abs(
x
)
function.
|
|
function-designator
||
|(
assignment-statement
)| |
|||
---------------------------------------------------------------------------------------------
The most significant difference between SPL and HP C/XL arithmetic
expressions is that SPL allows no type mixing, whereas HP C/XL performs
automatic type conversions during the evaluation of an expression.
Normally, this is very convenient and produces the desired result.
Occasionally, type "cast" operators may be required to force HP C/XL to
adhere to SPL-like operations. Particular caution must be observed with
any bit manipulations, as an automatic type conversion may result in an
unexpected change in word size.
Sequence of Operations (Arithmetic)
Table 5-20. Order of Evaluation of Arithmetic Operators
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Order of evaluation: | Same as SPL, except for the following: |
| | |
| | |
| 1. bit operations | bit operations Implemented as function |
| expressions in parentheses | calls; same sequence |
| expressions in backslashes | level. |
| function designators | |
| assignment statements in parentheses | absolute value (expressions in |
| | backslashes) Implemented |
| | as function call; same |
| 2. exponentiation | sequence level. |
| | |
| 3. multiply | exponentiation Implemented as function |
| divide | call; collapses into first |
| modulus | level; care needed in |
| | converting operands. |