# UNPACK

You can use the UNPACK function to do arithmetic with a packed decimal number or to move a packed decimal value into a numeric item.

UNPACK converts text that can be interpreted as a packed decimal number to a signed integer item.

The sign values for packed data are as follows:

- C for positive (+)
- D for negative (-)
- F for unsigned, which is read as positive
- Syntax:
- UNPACK ( single-fixed-size-text-expression )
- Meaning:
- UNPACK ( text_to_unpack )
- Returns:
- A single signed integer

UNPACK returns a signed integer
representing the value `text_to_unpack,` which is a packed
decimal number. If the `text_to_unpack` cannot be interpreted
as a valid packed decimal, UNPACK evaluates to "none".

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

- UNPACK ( "1L" ) returns 314
The ASCII string "1L" in hex is 31 4C, which, when interpreted as a packed number, results in (positive) 314. This example returns the value "+314".

The hexadecimal representation of the value "1L" is x`14C', where C in the rightmost half-byte represents a positive sign.

- UNPACK ( UnitPrice ) / 100 * QuantityOrdered
**UnitPrice**is unpacked and divided by 100 (to convert it from an integer to a number with two decimal places) and then multiplied by the`QuantityOrdered`.You can 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 functions

- PACK