HP Pascal/iX Reference Manual (31502-90022)

4-: 7
type, and if the operand is bit32 or bit52, the result is a longint. The
type of the result of a binary operator is the same as the data types of
its operands, provided that both operands are of the same type. Special
rules apply for division and in cases where operands have different data
types.
Implicit Type Conversion of Operands
The operators +, -, *, and / permit operands with different numeric
types. For example, it is possible to add an
integer
and a
real
number.
The compiler converts the integer to a real number, and the result of the
addition is real.
This
implicit conversion
of operands relies on a ranking of numeric
types. This is defined as follows:
RANK TYPE
highest longreal
. real, longint, bit52
. integer, bit32
lowest sub-integer
The rank of the value the result of an operation is the same as the
highest rank of all the operands. Operands having types whose ranks are
less than the rank of the type of the result are converted prior to the
operation, so that they have a type with a rank equal to that of the
result type.
For example, if i is an integer and x is a real in the expression (x +
i), then i is converted to real before the addition. In short, the two
operands to an arithmetic operator must be compatible. For more details,
refer to the section "Type Compatibility" .
Table 4-3. Type Comparisons and Results
---------------------------------------------------------------
| |
| Operand A Type Operand B Type Results |
| |
---------------------------------------------------------------
| |
| sub-integer sub-integer sub-integer |
| |
| sub-integer integer integer |
| |
| sub-integer real real |
| |
| integral-type longreal longreal |
| |
| integer real real |
| |
| integer super-integer longint |
| |
| integral-type longint longint |
| |
| longint real longreal |
| |
| real super-integer longreal |
| |
| real longreal longreal |
| |
| bit16 bit32 bit32 |
| |
| bit16 bit52 bit52 |
| |
| bit32 bit52 bit52 |
| |
---------------------------------------------------------------