Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Numeric Calculations →  System Classes for Numbers 

System Class CL_ABAP_MATH

Other versions: 7.31 | 7.40 | 7.54

Constants for Minimum and Maximum Values

The class CL_ABAP_MATH contains constants with the limits of the value ranges built-in numeric types.


Displays the minimum values and maximum values of numeric types.

  |i:          { cl_abap_math=>min_int4 WIDTH = 20 
          } to { cl_abap_math=>max_int4 WIDTH = 20 } \n| && 
  |int8:       { cl_abap_math=>min_int8 WIDTH = 20 
         } to { cl_abap_math=>max_int8 WIDTH = 20 } \n| && 
  |decfloat16: { cl_abap_math=>min_decfloat16 STYLE = SCIENTIFIC 
                                            WIDTH = 20 
          } to { cl_abap_math=>max_decfloat16 STYLE = SCIENTIFIC 
                                             WIDTH = 20 } \n| && 
  |decfloat34: { cl_abap_math=>min_decfloat34 STYLE = SCIENTIFIC 
                                            WIDTH = 20 
          } to { cl_abap_math=>max_decfloat34 STYLE = SCIENTIFIC 
                                             WIDTH = 20 } \n| ).

Operations with Floating Point Numbers

The class CL_ABAP_MATH contains methods for operations with floating point numbers.

Rounding Binary Floating Point Numbers

The method ROUND_F_TO_15_DECS rounds a binary floating point number to 15 places using commercial rounding.


Commercial rounding to 15 digits can also be done using the built-in function round, the result of which then has the decfloat34 type.


The example shows how rounding errors in the output formatting of binary floating point numbers can be prevented by two-step rounding using the method ROUND_F_TO_15_DECS. Instead of the method call, the function call round( val = float dec = 15 ) can be used here.

DATA float TYPE f VALUE '1.005'. 

  |{ float DECIMALS = 2 }\n| && 
  |{ cl_abap_math=>round_f_to_15_decs( float ) DECIMALS = 2 }\n| ).

Operations with Decimal Floating Point Numbers

  • The method NORMALIZE gets a normalized floating point number. This means that the scaling and precision of an input value are changed so that the mantissa has no trailing zeroes.

  • The method GET_SCALE_NORMALIZED gets the scaling of a normalized decimal floating point number. If the input value has decimal places, the return value is the number of decimal places without trailing zeroes.

  • The method GET_MAX_DB_VALUE gets the maximum value of a number of the type DF16_DEC or DF34_DEC on the database.

  • The method GET_DB_LENGTH_DECS gets the length and number of decimal places of a number of the type DF16_DEC or DF34_DEC on the database.


The rounding functions round and rescale can be used to round and rescale decimal floating point numbers.


Displays the scaling and precision of a decimal floating point number.

DATA(decf) = CONV decfloat34( '1234.56789' ). 

 |value = { decf 
 }\nscale = { cl_abap_math=>get_scale( decf ) 
 }\nprecision = { cl_abap_math=>get_number_of_digits( decf ) }| ).

This translation does not reflect the current version of the documentation.