📜  Rexx-操作员

📅  最后修改于: 2020-11-02 03:58:15             🧑  作者: Mango


运算符是一个符号,告诉编译器执行特定的数学或逻辑操作。

Rexx具有各种类型的运算符,下面还将对其进行详细说明-

  • 算术运算运算符
  • 关系运算符
  • 逻辑运算符
  • 按位运算符

算术运算符

Rexx语言支持普通的算术运算符,就像任何一种语言一样。以下是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

关系运算符

关系运算符允许对象的比较。以下是Rexx中可用的关系运算符。在Rexx中,真值用1表示,假值用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

逻辑运算符

逻辑运算符用于评估布尔表达式。以下是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

按位运算符

Groovy提供了四个按位运算运算符。下面是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

运算符优先级

下表按优先级从高到低的顺序显示了Rexx运算符优先级。

Operators Precedence
Prefix operators + – \
Addition and subtraction + –
Comparison operators = == > < >= <=
Logical AND &
Logical OR |
EXCLUSIVE OR &&