Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Perl Unpack Cobol Binary File and Fields

by Anonymous Monk
on May 04, 2020 at 21:45 UTC ( [id://11116454]=note: print w/replies, xml ) Need Help??


in reply to Perl Unpack Cobol Binary File and Fields

See: https://www.ibm.com/support/knowledgecenter/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/concepts/cpari09.htm

PACKED-DECIMAL and COMP-3 are synonyms. Packed-decimal items occupy 1 byte of storage for every two decimal digits you code in the PICTURE description, except that the rightmost byte contains only one digit and the sign. This format is most efficient when you code an odd number of digits in the PICTURE description, so that the leftmost byte is fully used. Packed-decimal items are handled as fixed-point numbers for arithmetic purposes.

The digits are stored left-to-right as decimal numbers, two digits per byte. The rightmost nybble is a sign indicator ... unless SIGN IS SEPARATE.

https://www.ibm.com/support/knowledgecenter/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/ref/rpari25.htm

Positive can be $C, $A, $E, $F; negative can be $D, $B. So the numeric value -(0)123 might be $000102030B.

  • Comment on Re: Perl Unpack Cobol Binary File and Fields

Replies are listed 'Best First'.
Re^2: Perl Unpack Cobol Binary File and Fields
by Anonymous Monk on May 06, 2020 at 13:33 UTC

    so it turns out mike is a cobol expert. things make a little more sense now. :eyeroll:

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Perl Unpack Cobol Binary File and Fields
by Anonymous Monk on May 04, 2020 at 22:01 UTC

    See: https://www.ibm.com/support/knowledgecenter/SS6SG3_5.2.0/com.ibm.cobol52.ent.doc/PGandLR/ref/rlddepic.html

    The V symbol used in a PICTURE clause indicates the position of an assumed decimal point. This is not present in the data. So, the value 123.45 with PIC 9(3)V99 might appear as $01020304050C. With a different picture, the identical data could be interpreted as 12345, 1.2345, 12.345 and so on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found