Table 3-1. JALv2 Operators
|COUNT||returns the number of elements in an array||UNIVERSAL|
|WHEREIS||return the location of an identifier||UNIVERSAL6|
|DEFINED||determines if an identifier exists||BIT|
|'(' expr ')'||Grouping||Result of evaluating expr|
|'-'3||Unary - (negation)||Same as operand|
|'+'3||Unary + (no-op)||Same as operand|
|'!'||1's complement||Same as operand|
|'!!'3||Logical. If the following value is 0, the result is 0, otherwise the result is 1.||BIT|
|'%'5||Modulus division (remainder)||Promotion2|
|'<'3||Strictly less than||BIT|
|'<='3||Less or equal||BIT|
|'>='3||Greater or equal||BIT|
|'>'3||Strictly greater than||BIT|
|'^'||Binary exclusive OR||Promotion2|
1shift right: If the left operand is signed, the shift is arithmetic (sign preserving). If unsigned, it is a simple binary shift.
2promotion: The promotion rules are tricky, here are the cases:
|If either operand is FLOAT, the result is FLOAT.|
|If one of the operands is UNIVERSAL and the other is not, the result is the same as the non-UNIVERSAL operand.|
|If both operands have the same signedness and width, the result is that of the operands.|
|If both operands have the same width, and one is unsigned, the result is unsigned.|
|If one operand is wider than the other, the other operand will be promoted to the wider type.|
3These operators allow FLOAT types.
4Floating point numbers should never be compared for equality due to the imprecise way in which they are stored. Attempting to do so will result in a warning from the compiler. Two different operations which should yield an identical mathmatical result may compare unequal. The correct way to compare two floating point numbers, say A and B, is `abs((A - B)/B) < 1e-6' (floating point values have a nominal precision of 6 - 9 digits).
5Keep in mind that multiplication and division, even between integer types are very expensive operations in both code size and data size (see Chapter 11: Build-in Function).
6The result of WHEREIS depends upon the identifier used:
A procedure or function will return the CODE address of the entry point.
An assembly label will return the CODE address of the label.
A variable will return the DATA address of the variable.
A simple constant will generate an error.
A constant array depends upon the processor family:
16-bit: returns the CODE address of the data.
non-16 bit: returns the CODE address of the entry point to the lookup function.