IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Converting Packed decimal S9(11)V99 to unpacked Decimal


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandeshgitte

New User


Joined: 08 Jul 2006
Posts: 4

PostPosted: Thu Jul 27, 2006 10:53 am
Reply with quote

Hi,

I have a variable S9(11)V99 COMP-3. I want to convert it to Unpacked Decimal.

Can anyone help me in this regard. It would be helpful if you can give me the code and the MOVE statement.

Thanks for your time,
Sandesh Gitte
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jul 28, 2006 5:33 am
Reply with quote

Hi Sandesh,

There is no format in COBOL that is discussed as ?Unpacked Decimal?. What you meant, I?m sure, is ?Zoned Decimal? OR ?NUMERIC-EDITED? . There is also Binary, and Floating Point, but I don?t think this is what you meant.

I?ll briefly discuss Packed-Decimal, Zoned-Decimal, Numeric-Edited, and Binary. The Floating-Point format should wait until another time after you well understand these four.

Code:

    01  WS-PACKED-DECIMAL PIC S9(11)V99   COMP-3 VALUE 1542.16.
    01  WS-ZONED-DECIMAL  PIC S9(11)V99.
    01  WS-BINARY         PIC S9(11)V99   COMP.
    01  WS-NUMERIC-EDIT   PIC 99,999,999.99.


In a Packed-decimal, Zoned-decimal, Binary, the ?Decimal Point? is assumed, and is not held in the stored value. Numeric-Edited, on the other hand contains all of the editing characters in the stored value.

The hex value stored in each of these formats, assuming the 1542.16 value is:

Packed-Decimal:
X?00000154216C? where the ?C? is held as the sign. ?C? = Positive, ?D? = negative, and ?F? = unsigned.

Zoned_Decimal:
X?F0F0F0F0F0F1F5F4F2F1C6? Where the ?F? is the ZONE, and has no real impact on the number, ?C? is held as the sign, as above.

Numeric_Edited:
X?F0F06BF0F0F16BH5H4H24BF1F6? This is a Display format, the X?6B? = ?,? AND X?4B? = ?.?. This would display, or print as ?00,001,542.16?.

Binary:
X?0000000000025A68?. The sign is the high order Bite 0 = pos 1 = neg. Below are the Binary values for +1542.16 and -1542.16
B?0000000000000000000000000000000000000000000000100101101001101000?
B?1111111111111111111111111111111111111111111111011010010110011000?

To convert from the Zoned-Decimal format to the others is pretty straight forward.

Code:

    MOVE WS-PACKED-DECIMAL   TO WS-ZONED-DECIMAL.
    MOVE WS-PACKED-DECIMAL   TO WS-BINARY.
    MOVE WS-PACKED-DECIMAP   TO WS-NUMERIC-EDITED.


If there is confusion, please come back.

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top