SPL to HP C/XL Migration Guide (30231-90001)
5-21
Conversion Issues
SPL NOT Operator.
SPL uses the same operator, NOT, for both bitwise negation and Boolean
negation. HP C/XL uses two operators: "~" (tilde) for bitwise negation
and "!" for Boolean negation. They give different results, as shown in
Table 5-23.
Table 5-23. Logical and Bitwise Negation
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| NOT(0) = -1
(or
LOGICAL 65535
)
| ~(0) == -1
(or
unsigned 4294967295
)
|
|
16 off bits turned on
|
32 off bits turned on
|
| | !(0) == 1 |
| |
since 0 means false
|
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| NOT(-1) = 0 | ~(-1) == 0 |
|
16 on bits turned off
|
32 on bits turned off
|
| | !(-1) == 0 |
| |
since nonzero means true
|
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| NOT(%(16)F0F0) = %(16)0F0F | ~(0xF0F0) == 0xFFFF0F0F |
|
16 bits negated
|
32 bits negated
|
|
original value is false
|
both values are true
|
|
result value is true
| !(0xF0F0) == 0 |
| |
since nonzero means true
|
| | |
---------------------------------------------------------------------------------------------
The HP C/XL "~" operator is probably the better first-pass replacement
for the SPL NOT.
SPL TRUE and FALSE Constants.
SPL returns a 16-bit LOGICAL 65535 (INTEGER -1) for true and 0 for false.
However, when
testing
a value for true or false in a condition clause,
SPL examines only bit 15 for 1 or 0, ignoring bits 0-14.
HP C/XL returns a 32-bit integer 1 for true and 0 for false. When
testing a value for true or false, HP C/XL tests the whole number for
nonzero or 0.
These variations will have no effect on the value of a condition clause
except if the expressions in the clause use the returned true or false
values numerically, as in bit manipulation.
Many SPL programmers have taken advantage of the way SPL tests bit 15 for
true or false, and existing SPL code must be carefully examined for
examples of this practice. Too direct a translation of bit operations