Rexx-arithmetic-operators
提供:Dev Guides
Rexx-算術演算子
Rexx言語は、すべての言語として通常の算術演算子をサポートしています。 以下は、Rexxで使用可能な算術演算子です。
Operator | Description | Example |
---|---|---|
PLUS | Addition of two operands | 1 PLUS 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 |
例
次のプログラムは、さまざまな演算子の使用方法を示しています。
/* Main program*/
X = 40
Y = 50
Res1 = X + Y
Res2 = X - Y
Res3 = X * Y
Res4 = X/Y
Res5 = X % Y
Res6 = X//Y
say Res1
say Res2
say Res3
say Res4
say Res5
say Res6
上記のプログラムの出力は次のようになります-
90
-10
2000
0.8
0
40