Packed-Decimal Numbers [ Compiler Library/XL Reference Manual ] MPE/iX 5.0 Documentation
 
  
  
  
 
Compiler Library/XL Reference Manual
Packed-Decimal Numbers 
The format of a packed-decimal number is shown in Figure 4-1.
          Figure 4-1.  Packed-Decimal Format 
The left-most byte in the illustration contains the high-order digit.  If
this digit is in bit postions 4 through 7, positions 0 through 3 of the
same byte are ignored.  (A digit count specifies the number of digits
to be recognized.)  A packed-decimal number has the following
characteristics:
 *  Each decimal digit is represented in binary coded decimal (BCD) form
    by four bits.
 *  The sign is represented by four bits.
 *  In storage, the four sign bits may be in the following bit positions
    of a 32-bit word:  (4-7), (12-15), (20-23), or (28-31).  Expressed in
    different terms, the sign is always in positions (4-7) of an 8-bit
    byte; the byte is byte 0, byte 1, byte 2, or byte 3 of a 32-bit word.
 *  Bytes to the left of the byte containing the high-order digit are not
    part of the number field and may have any contents, even though they
    may be part of the same 32-bit word.  Likewise, bytes to the right of
    the byte containing the sign bits are not part of the field and may
    have any contents, even though they may be part of the same 32-bit
    word.  Bytes that are outside of the field will not be accessed or
    modified.
 *  Succeeding 4-bit groups to the left of the sign (Figure 4-1) can
    contain successively higher-order digits.
 *  There are no unused bits between the sign and the high-order digit.
 *  The length may be up to 28 digits.
 *  The storage address is the address of the byte that contains the
    high-order digit.
 *  When a packed-decimal number is source data for a decimal arithmetic
    procedure, sign bits 1101 are recognized as minus.  All other bit
    combinations are recognized as plus, except that HPPACCVDA recognizes
    1111 as designating an unsigned number.
 *  When a packed-decimal number is the result of a decimal arithmetic
    procedure, sign bits 1100 indicate plus and 1101 indicate minus.
    There are no unsigned result operands except for HPPACCVAD, which
    furnishes 1111 to indicate an unsigned number.
 *  A leading nonsignificant packed-decimal digit is not modified by any
    procedure other than HPPACCVAD, which inserts a zero.
 
  
  
  
 
 MPE/iX 5.0 Documentation