PACK

The PACK function converts an integer to a text item that can be interpreted as a packed decimal number.

The sign values for packed data are as follows:

  • C for positive (+)
  • D for negative (-)
  • F for unsigned, which is read as positive
    Syntax:
    PACK (single-integer-expression)
    Meaning:
    PACK (integer_to_conver)
    Returns:
    A single text item

In a packed decimal number, each half-byte is a digit, except for the last half-byte of the rightmost byte, which contains a sign.

Examples

  • PACK (314)

    Returns "1L" and results in the hex value 31 4C (which, in ASCII, looks like 1L)

  • PACK ((Unit Price * Quantity) * 100)

    In this example, the packed number has two implied decimal places. Because PACK does not accept decimal places, including implied ones, the nested arithmetic expression, Unit Price * Quantity, is multiplied by 100 before rounding.

    Define items as having a packed decimal number presentation. Then, when mapping to or from these items, the conversion to and from packed decimal is automatically performed as needed.

Related function

  • UNPACK

Feedback