Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting Packed decimal S9(11)V99 to unpacked Decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Converting Packed decimal S9(11)V99 to unpacked Decimal
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    Post subject: Re: Converting Packed decimal S9(11)V99 to unpacked Decimal
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us