SAP FLOATING POINT CLASS



Get Example source ABAP code based on a different SAP table
  


VERSION 5 IN
• CL_ABAP_MATH ABAP_CLASS

System Class CL_ABAP_MATH
ITOC

Constants for Minimum and Maximum Values
The class CL_ABAP_MATH contains constants with the limits of the value ranges built-in numeric types.

ABAP_EXAMPLE_VX5
Display of the minimum and maximum values of numeric types.
ABEXA 01028
ABAP_EXAMPLE_END

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.



Latest notes:

Commercial rounding to 15 digits can also be achieved using the built-in function round, the result of which, however, has the decfloat34 type.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
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.
ABEXA 01029
ABAP_EXAMPLE_END

Operations with Decimal Floating Point Numbers
The method GET_SCALE returns the scaling of a decimal floating point number.
The method GET_NUMBER_OF_DIGITS returns the precision of a decimal floating point number.
The method NORMALIZE returns 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 zeros.
The method GET_SCALE_NORMALIZED returns 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 zeros.
The method GET_MAX_DB_VALUE returns the maximum value of a number of the type DF16_DEC or DF34_DEC on the database.
The method GET_DB_LENGTH_DECS returns the length and number of decimal places of a number of the type DF16_DEC or DF34_DEC on the database.



Latest notes:

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

ABAP_EXAMPLE_VX5
Display of the scaling and precision of a decimal floating point number.
ABEXA 01030
ABAP_EXAMPLE_END