Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments →  Assignment and Conversion Rules →  Conversion Rules for Elementary Data Objects →  Numeric Source Fields 

Source Field Type decfloat16, decfloat34

If the source field does not contain a valid decimal floating point number, the handleable exception CX_SY_CONVERSION_NO_NUMBER is raised, except in the case of the assignment to another decimal floating point number. In ABAP, invalid decimal floating point numbers also include the special values "+Infinity", "-Infinity", "NaN", and "sNaN", which represent infinity or invalid numbers and are designated in the IEEE-754-2008 standard.

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Fields

Target Conversion
i, (b, s) The value of the decimal floating point number is rounded up to the nearest integer. If this number is within thevalue range for the data type i,(b, s), it is converted to the internal representationof the corresponding integer number. If the number is not within this range, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
p The value of the decimal floating point number is rounded to the number ofdecimal places inthe target field. If this number is within the value range for the data type of the target field, itis converted to the internal representation of a packed number. If the number is not within this range, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
decfloat16, decfloat34 If an assignment is made to the same data type, the content is passed unconverted. For an assignmentfrom decfloat34 to decfloat16 the mantissa is shortened from 34 to 16 places, and commercially rounded if necessary. If the mantissa of the target field is long enough, thescaling is preserved. If thevalue range of decfloat16 is exceeded, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
f The value of the decimal floating point number is applied in the value of a binary floating pointnumber. If the decimal number cannot be represented as a binary floating point number, the nearest valueis used. If the value is outside the value range for floating point numbers, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.

Character-Like Target Fields

Target Conversion
c The content of the source field is first converted into amathematical orscientific notation,as described for the data type string. The result of this conversion is thencopied, right-justified into the target field. If the target field is longer than the text string, thespace to the left is padded with blanks. If the target field is shorter than the text string, mathematicalnotation is converted into scientific notation and if necessary the mantissa is commercially rounded.If the length is not sufficient for at least one digit of the mantissa, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
string If the exponent of the decimal floating point number is less than 0 and the absolute value of the number is bigger than 1E-6, the floating point number is formatted as follows intomathematical notationwithout spaces: The numeric sequence is made up of the mantissa of the decimal floating point numberwithout leading zeroes. If the exponent of the decimal floating point number is less than 0, a decimalpoint is inserted at the corresponding position. If the exponent of the decimal floating point number is greater than 0 or the absolute value of the number is less than 1E-6, the floating point number is formatted as follows intoscientific notation:The mantissa is made up of the mantissa of the decimal floating point number without leading zeroes.If the mantissa contains more than one decimal place, a decimal point is inserted after the first place.The exponent is always displayed with algebraic sign and without leading zeroes. In both depictionsthe algebraic sign is displayed for negative values but not for positive. Both depictions are also usedif the value of the decimal floating point number is 0. The maximum length of the target field is 24 for decfloat16 and 42 for decfloat34.
n The value of the decimal floating point number is rounded up to the nearest integer. The absolutevalue is passed as a right-aligned character string to the target field. If the target field is longerthan the character string, the field is padded with zeroes from the left. If it is too short, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
d The content of the source field is first converted to the data type i(see above), and then to the type d (see the conversion table for source field type i,(b, s)).
t The content of the source field is first converted to the data type i(see above), and then to the type t (see the conversion table for source field type i,(b, s)).


Notes

  • The conversion rule for floating point numbers to text strings is as follows: a text string filled by the assignment of a decimal floating point number produces the same internal representation as in the original decimal floating point number (preserves the scaling).

Examples

The following table shows how decimal floating point numbers are converted to text strings:

Floating Point Number Text String
123E+0 123
123E+1 1.23E+3
2E+1 2E+1
1230E-2 12.30
5E-6 0.000005
50E-7 0.0000050
5E-7 5E-7
50E-8 5.0E-7
-0E+0 -0
0E-100 0E-100

Byte-Like Target Fields

Target Conversion
x The content of the source field is first converted to the data type i(see above), and then to the type x (see the conversion table for source field type i,(b, s)).
xstring The content of the source field is first converted to the data type i(see above), and then to the type x (see the conversion table for source field type i,(b, s)).