Let’s introduce what the arithmetic operators mentioned above can be described as instructions.
Command | Meaning |
---|---|
ADD | Addition |
SUBTRACT | Subtraction |
MULTIPLY | Multiplication |
DIVIDE | Division |
ADD:Addition
DATA: result TYPE I. result = 3. ADD 2 TO result.
First, the variable: result is set to 3, and then 2 is added. Since ADD 2 TO 3 has the same meaning as 3 + 2, 5 is set to the variable: result as a result. The part described as 2 can be described as a variable.
SUBTRACT:Subtraction
DATA: result TYPE I. result = 3. SUBTRACT 2 FROM result.
First, the variable: result is set to 3, and then 2 is subtracted. SUBTRACT 2 FROM 3 has the same meaning as 3-2, so 1 is set as the result: variable: result.
MULTIPLY:Multiplication
DATA: result TYPE I. result = 3. MULTIPLY result BY 2.
First, the variable: result is set to 3, and then it is multiplied by 2. Since MULTIPLY 3 BY 2 has the same meaning as 3 * 2, 6 is set to the variable: result as a result.
DIVIDE:Division
DATA: result TYPE I. result = 6. DIVIDE result BY 2.
First, set the variable: result to 6, and then divide it by 2. Since MULTIPLY 6 BY 2 has the same meaning as 6/2, 3 is set as the result: variable: result.
Recent Comments