ABAP Keyword Documentation → ABAP - Reference → Program Flow → Expressions and Functions for Logical Expressions → log_exp - Logical Expressions → log_exp - Comparisons → log_exp Comparison Rules → log_exp - Comparing Elementary Data Types → log_exp - Comparisons of Elementary Data Objects
log_exp - Comparing Numeric Data Types
The following tables show the comparison types for comparisons between numeric data types and other data types. If the type of an operand is not the same as the comparison type, then it is converted to this type.
Other versions: 7.31 | 7.40 | 7.54
Note
If a decimal floating point number is involved in a comparison, the comparison is always made with the type decfloat34
.
Comparisons with Numeric Data Types
- | decfloat34 | decfloat16 | f | p | i | s | b |
---|---|---|---|---|---|---|---|
decfloat34 | decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat16 | decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
decfloat34 |
f | decfloat34 |
decfloat34 |
f |
f |
f |
f |
f |
p | decfloat34 |
decfloat34 |
f |
p |
p |
p |
p |
i | decfloat34 |
decfloat34 |
f |
p |
i |
i |
i |
s | decfloat34 |
decfloat34 |
f |
p |
i |
s |
s |
b | decfloat34 |
decfloat34 |
f |
p |
i |
s |
b |
Value Ranges and Length Adjustments
- When two operands with data type
p
are compared, numbers with more than 31 decimal places are edited internally to ensure that there is no overflow.
- When two operands with data type
p
but with different lengths are compared, the shorter operand is converted to the length of the longer operand.
- When two operands with data type
p
but with different numbers of decimal places are compared, the operand with fewer decimal places is converted to a number with the same number of decimal places as the other operand.
- When an operand with type
p
is compared with an operand with type i,s
, orb
, the comparison typep
has 31 decimal places and the number of decimal places of the operand of typep
.
Comparisons with Character-Like Data Types
- | decfloat34 | decfloat16 | f | p | i | s | b |
---|---|---|---|---|---|---|---|
d,t | decfloat34 |
decfloat34 |
f |
p |
i |
i |
i |
string, c, n | decfloat34 |
decfloat34 |
f |
p |
See below |
See below |
See below |
When the types string
, c
, and n
are compared with whole numbers of the types int8
, i
,
s
, and b
, a strict conversion to a comparison type does not take place. The content of the character-like operand must meet the prerequisites for a
conversion to a numeric value, however this
value must be within a value range and there must be no exception due to an overflow. A comparison of this type always produces the right result, regardless of the value range of the numeric data type.
Length Adjustments
The comparison type p
has 31 decimal places and the number of places in the decimal portion in the operand of type p
.
Comparisons with Byte-Like Data Types
- | decfloat34 | decfloat16 | f | p | i, s, b |
---|---|---|---|---|---|
xstring, x | decfloat34 |
decfloat34 |
f |
p |
i |
Length Adjustments
The comparison type p
has 31 decimal places and the number of places in the decimal portion in the operand of type p
.
Note
When converting byte-like data types to numeric types, note that all bytes are ignored except for the final four.