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

arith_exp - Calculation Type

An arithmetic expression is assigned a calculation type that specifies how the arithmetic expression is to be handled. The calculation type is determined at program runtime from those data types involved that can be identified. The calculation type only needs to be determined statically if the target field is an inline declaration, where generically typed operands are included using a standard type.

Determining the Calculation Type

The calculation type corresponds to one of the numeric data types i, p, f, or decfloat34. It is determined according to the following hierarchy, and in this order of priority:

  1. If one of the data types involved is decfloat16 or decfloat34, the calculation type is decfloat34.

  2. If one of the data types involved is f or if the operator ** is used, the calculation type is f.

  3. If one of the data types involved is p, the calculation type is p.

  4. If one of the data types involved is i, (b or s), the calculation type is i.

The data type that has the largest value range therefore determines the calculation type. An exception to this is that each decimal floating point number produces the calculation type decfloat34, and that using the operator ** is handled like a data type of type f.

Involved data types include:

For operands with complete numeric data types, this data type is used. Operands with other data types are handled as follows:

In the case of operands not specified as data objects, the type is determined as follows:

The calculation type determined at runtime from all operands (including the target field) always matches the data type of the variable declared inline, because this is always the data type with the greatest value range.

Notes

Meaning of the Calculation Type

Before the calculation is made, all operands (where this is required) are converted to the calculation type, in accordance with the conversion rules for elementary data types.

The calculation type determines the calculation method and the calculation accuracy:

Handling the Result

After the calculation is performed, the result of the arithmetic expression is handled as follows: