ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Numeric Calculations →  arith_exp - Arithmetic Expressions → 

arith_exp - Arithmetic Operators

The table below shows the possible arithmetic operators for arithmetic expressions, their priority, and the order in which the calculation is performed. Within one parenthesis level, calculations with operators of higher priority are performed before calculations with operators of lower priority. For consecutive operators of the same priority, the calculation is performed in the order specified. In the third column of the table below, 3 indicates the highest priority and 1 the lowest. With the exception of **, the operators have no effect on the calculation type. If the operator ** does not appear in an arithmetic expression, then the calculation type is determined only by the data types involved. When ** is used, the calculation type is either decfloat34 or f. The calculation type is decfloat34 if one of the operands used is a decimal floating point number, otherwise it is f.

Operator Calculation Priority Order
+ Addition of the operands 1 From left to right
- Subtraction of the right operand from the left 1 From left to right
* Multiplication of the operands 2 From left to right
/ Division of the left operand by the right 2 From left to right
DIV Integer part of the division of the left operand by the right, with positive remainder 2 From left to right
MOD Positive remainder of the division of the left operand by the right; a remainder other than zero is always between zero and the size of the right operand 2 From left to right
** Left operand raised to the power of the right 3 From right to left

Programming Guideline

Preventing Division by Zero

Notes

Example

The following table shows the results of integer divisions and their remainders.

operand1 operand2 div mod
7 3 2 1
-7 3 -3 2
7 -3 -2 1
-7 -3 3 2

Example

See Lossless Calculations

Example

Refer to Decimal Floating Point Numbers, Arithmetic Calculations.




Continue
Arithmetic Calculations
Floating Point Numbers, Arithmetic Calculations