Packed Decimal Conversion (MP)

Packed Decimal Conversion (MP)

Top  Previous  Next


The MP conversion code transforms a numeric value to or from packed decimal form (also known as Binary Coded Decimal, BCD).


The full format of this conversion code is





The MP conversion code used as an input conversion transforms a numeric value to packed decimal form where two digits are packed into each byte of the result string. Used as an output conversion, the MP conversion code expands a packed decimal value into an integer.


A negative value is indicated by the low order 4 bits of the final byte having the value 13 (hexadecimal D).


Because a packed decimal value always contains an even number of 4-bit values, a leading zero value is added at the start of the item if it would otherwise have an odd number of values.