DB2 codes for numeric data in edit and validation routines

DB2® stores numeric data in a specially encoded "DB2-coded" format .

Begin program-specific programming interface information.
To retrieve numeric data in its original form, you must DB2-decode it according to its data type:
Table 1. DB2 decoding procedure according to data type
Data type DB2 decoding procedure
SMALLINT Invert the sign bit (high-order bit).
Value
Meaning
8001
0001 (+1 decimal)
7FF3
FFF3 (-13 decimal)
INTEGER Invert the sign bit (high-order bit).
Value
Meaning
800001F2
000001F2 (+498 decimal)
7FFFFF85
FFFFFF85 (-123 decimal)
FLOAT If the sign bit (high-order bit) is 1, invert only that bit. Otherwise, invert all bits.
Value
Meaning
C110000000000000
4110000000000000 (+1.0 decimal)
3EEFFFFFFFFFFFFF
C110000000000000 (-1.0 decimal)
DECIMAL Save the high-order hexadecimal digit (sign digit). Shift the number to the left one hexadecimal digit. If the sign digit is X'F', put X'C' in the low-order position. Otherwise, invert all bits in the number and put X'D' in the low-order position.
Value
Meaning
F001
001C (+1)
0FFE
001D (-1)
BIGINT Invert the sign bit (high order bit).
Value
Meaning
8000000000000854
0000000000000854 (2132 decimal)
7FFFFFFFFFFFFFE0
FFFFFFFFFFFFFFE0 (-32 decimal)
DECFLOAT Convert and return a DECFLOAT representation of a number or string representation of a number.
Value
Meaning
D8F77D00000000000C
222C000000001E80 (+7.500 decfloat)
270882FFFFFFFFFFF2
A2300000000003D0 (-7.50 decfloat)
End program-specific programming interface information.