RE: IBM packed decimal format conversion utilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 06, 2002 at 04:32:10PM -0500, Paul Hamm wrote:
> I am familiar with EBCDIC and ASCII conversion with dd.  Currently I need
> to
> convert a mainframe tape in EBCDIC with packed decimal format into ASCII.
> dd does not handle packed decimal format.  Does anyone know of a utilitie
> that does? 

Packed decimal isn't all that difficult to deal with directly.  From one
to 16 bytes may be used to represent an arithmetic value.  A pattern of
4 bits is used to represent a decimal digit.  Since a byte has 8 bits,
up to two digits can be "packed" into a single byte.  One half of a byte
is reserved for the algebraic sign.  The bit pattern 1100 represents a
plus (+) sign and the pattern 1101 represents a minus (-) sign.  So, for
example, to represent +5 the following is used.

0101 1100  -- Hex 5C

The sign is always the rightmost 4 bits of the right most byte.

To represent -12, the following is used.

0000 0001 0010 1101  -- hex 01 5D

To represent +789...

0111 1000 1001 1100   -- hex 78 9C

Mainframes actually have machine instructions which deal with this
format directly.  There are instructions like AP (add decimal), CP
(compare decimal), DP (divide decimal), etc, which operate against this
kind of data.

-- Rich

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux