The following arithmetic operators can be used in ABAP.
演算子 | 計算 |
---|---|
+ | Operand addition |
– | Subtract right operand from left operand |
* | Operand multiplication |
/ | Division of left operand by right operand |
DIV | Integer part of quotient of division of left operand by right operand |
MOD | Integer part of remainder of left operand division by right operand |
** | Left operand raised to right operand |
Since it is an explanation that is difficult to convey from the right HELP of the left operand, let’s explain each calculation formula based on an example.
+:Operand addition
DATA: v_result TYPE p DECIMALS 2. v_result = 110 + 25.
This is a formula for obtaining the result of simple addition. The variable: v_result is set to 135, which is 110 plus 25.
-:Subtract right operand from left operand
DATA: v_result TYPE p DECIMALS 2. v_result = 110 - 25.
This is a calculation formula for obtaining the result of a simple subtraction. The variable: v_result is set to 85, which is 110 minus 25.
*:Operand multiplication
DATA: v_result TYPE p DECIMALS 2. v_result = 110 * 10.
This is a formula for obtaining the result of simple multiplication. Variable: v_result is set to 110 multiplied by 10 and set to 1100.
/:Division of left operand by right operand
DATA: v_result TYPE p DECIMALS 2. v_result = 110 / 10.
This is a formula for obtaining the result of simple division. Variable: v_result is set to 11 by dividing 10 from 110.
DIV:Integer part of quotient of division of left operand by right operand
DATA: v_result TYPE p DECIMALS 2. v_result = 110 DIV 25.
This is a calculation formula for obtaining only the integer part from the result of division. Dividing 110 to 25 gives 4.4, but only the integer part of this result, 4, is set to the variable: v_result. It can be used when you want to cut off after the decimal point.
MOD:Integer part of remainder of left operand division by right operand
DATA: v_result TYPE p DECIMALS 2. v_result = 110 MOD 25.
This is a calculation formula for obtaining a value that is not divisible as a result of division. Dividing 110 by 25 gives 4 as the integer part. The remainder which is not divisible is set to the variable: v_result.
**:Left operand raised to right operand
DATA: v_result TYPE p DECIMALS 2. v_result = 10 ** 5.
The above is the formula to the power of 10 5. The result of 10 * 10 * 10 * 10 * 10 100000 is set to the variable: v_result.
Recent Comments