an operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
rexx has various types of operators which are also explained in detail as follows −
- arithmetic operators
- relational operators
- logical operators
- bitwise operators
arithmetic operators
the rexx language supports the normal arithmetic operators as any the language. following are the arithmetic operators available in rexx.
| operator | description | example |
|---|---|---|
| + | addition of two operands | 1 + 2 will give 3 |
| − | subtracts second operand from the first | 1 - 2 will give -1 |
| ∗ | multiplication of both operands | 2 ∗ 2 will give 4 |
| / | division of numerator by denominator | 2 / 2 will give 1 |
| // | remainder of dividing the first number by the second | 3 // 2 will give 1 |
| % | the div component will perform the division and return the integer component. | 3 % 2 will give 1 |
relational operators
relational operators allow of the comparison of objects. following are the relational operators available in rexx. in rexx the true value is denoted by 1 and the false value is denoted by 0.
| operator | description | example |
|---|---|---|
| == | tests the equality between two objects | 2 = 2 will give 1 |
| < | checks to see if the left object is less than the right operand. | 2 < 3 will give 1 |
| =< | checks to see if the left object is less than or equal to the right operand. | 2 =< 3 will give 1 |
| > | checks to see if the left object is greater than the right operand. | 3 > 2 will give 1 |
| >= | checks to see if the left object is greater than or equal to the right operand. | 3 > 2 will give 1 |
logical operators
logical operators are used to evaluate boolean expressions. following are the logical operators available in rexx.
| operator | description | example |
|---|---|---|
| & | this is the logical “and” operator | 1 or 1 will give 1 |
| | | this is the logical “or” operator | 1 or 0 will give 1 |
| \ | this is the logical “not” operator | \0 will give 1 |
| && | this is the logical exclusive “or” operator | 1 && 0 will give 1 |
bitwise operators
groovy provides four bitwise operators. below are the bitwise operators available in groovy.
| sr.no. | operator & description |
|---|---|
| 1 |
bitand this is the bitwise “and” operator |
| 2 |
bitor this is the bitwise “or” operator |
| 3 |
bitxor this is the bitwise “xor” or exclusive or operator |
operator precedence
the following table shows the operator precedence for the rexx operators in order of descending priority of their precedence.
| operators | precedence |
|---|---|
| prefix operators | + - \ |
| addition and subtraction | + - |
| comparison operators | = == > < >= <= |
| logical and | & |
| logical or | | |
| exclusive or | && |