Operators
Presents OPL and IBM ILOG Script operators and their order of precedence.
Traditional relational operators ==, !=, >=, >, <, and <= are used with:
integer expressions to construct integer relations
float expressions to construct float relations
string expressions to construct string relations.
Relations can be combined by using the traditional logical operators:
! (negation)
|| (disjunction)
&& (conjunction)
OPL operators
The OPL operators are listed here in a decreasing order of precedence.
Class | Operator |
---|---|
Aggregate | all |
Binary1 | ^ |
Aggregate | prod inter |
Binary | * / div % mod inter |
Aggregate | sum max min union |
Unary | + - ! |
Binary | + - union diff symdiff |
Range | .. |
Membership | in not in |
Relational | == <= >= < > != (<=.<=) (>=.>=) |
Logical | && and |
Logical | || or |
Logical | => |
Ternary | ?: |
1 ^ means power in OPL and bitwise xor in Script |
Example
range r=1..2;
int x[r]=[2,3];
// The priority of sum is greater than the priority of +
int s=sum(i in r) x[i] + 1;
execute
{
writeln("s = ",s);
}
Result
s = 6
Script operators
The IBM ILOG Script operators are listed here in a decreasing order of precedence.
Precedence | Operators | Operation performed |
---|---|---|
1 | [] . new | |
2 | () [] . | function call |
3 | ++ -- | postfix increment, postfix decrement |
4 | delete void typeof | delete, undefined return, return type |
++ -- + - | prefix increment, prefix decrement, unary plus, unary minus | |
~ ! | bitwise not, logical not | |
5 | * / % | multiplication, division, remainder |
6 | + - | addition, subtraction |
7 | << >> >>> | bitwise left shift, signed right shift, unsigned right shift |
8 | < <= > >= | less than, less than or equal to, greater than, greater than or equal to |
instanceof | call HasInstance method | |
in | call HasProperty method | |
9 | == != === !== | is equal, is not equal, is strictly equal, is strictly not equal |
10 | & | bitwise and |
111 | ^ | bitwise xor |
12 | | | bitwise or |
13 | && | logical and |
14 | || | logical or |
15 | ?: | conditional expression |
16 | = | Assignment |
*= /= %= += -= <<= >>= >>>= &= ^= |= | Assignment with ... | |
17 | , | Sequential evaluation |
1 ^ means power in OPL and bitwise xor in Script |