Expression type and precision
Primary (single-operator) expression type and calculation precision depends
on the operand that has higher precision class. There are 4 precision classes:
1. int (int, word, byte). In expressions, word and byte are implicitly converted
2. unsigned int (pointers (including lpstr and interface pointers), unsigned
3. long (long).
4. double (double, OLE types).
The following are the exceptions:
- If operator is logical or comparison,
expression type is int (result 0 or 1).
- Else, if both operands are lpstr or pointer, and operator
is -, expression type is int (difference between two pointers).
- Else, if operand1 is lpstr or pointer, and operand2 is int
(int, byte or word) or unsigned int, expression type is type of operand1.
- Before calculating a bitwise operator, operands are converted to unsigned
int or unsigned long.
- Before calculating the % operator (integer remainder), double operands are
converted to int or long.
Type of more complex expression can be found by splitting it to primary expressions.