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
 

 

Diff between Packed decimal and binary decimal formats

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
krbabu

New User


Joined: 20 Feb 2004
Posts: 57

PostPosted: Fri Feb 20, 2004 12:35 pm    Post subject: Diff between Packed decimal and binary decimal formats
Reply with quote

Hi ,
Can anybody tell me the differance between the packed decimal format and the binary decimal format.
Back to top
View user's profile Send private message

mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1202
Location: India

PostPosted: Fri Feb 20, 2004 2:32 pm    Post subject: Re
Reply with quote

Dear,

Binary Decimal is what you are defining as "COMP" and packed decimal is what you are thinking s "COMP-3"

In computational format data are stored in binary format and it occupies half / full / double word depending on the size of data.

In comp-3 format data are stored in 8421 decimal format and each digit occupies half-a-byte.
Back to top
View user's profile Send private message
krbabu

New User


Joined: 20 Feb 2004
Posts: 57

PostPosted: Mon Feb 23, 2004 12:08 pm    Post subject: can u give one example
Reply with quote

Hi Millan,
Thanks to your valuabel guidance, Can u give the example for the following number.
How can the number 126 stored in two formats , both the comp and comp-3.Can explain the internal format for 126 in both the cases.
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1202
Location: India

PostPosted: Mon Feb 23, 2004 12:18 pm    Post subject: Re
Reply with quote

Sure,

126 in COMP: 0000 0000 0111 1110 (2 bytes)

126 IN COMP-3: 0001 0100 0110 1111 (2 bytes)
Back to top
View user's profile Send private message
krbabu

New User


Joined: 20 Feb 2004
Posts: 57

PostPosted: Thu Feb 26, 2004 1:30 pm    Post subject:
Reply with quote

Thanks millan,

i am in confusion about, how to mention the digits in comp-3 format.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Feb 28, 2004 6:53 am    Post subject:
Reply with quote

Hi Ravindra,

If you saw the 2 representations that McMillan presented in a dump they would look like this:

PIC 9(003) COMP-3 VALUE 126 ===> 126F
PIC 9(003) COMP VALUE 126 ===> 007E

The minus values might surprise you:

PIC S9(003) COMP-3 VALUE -126 ===> 126D
PIC S9(003) COMP VALUE -126 ===> FF82

If I did the math correctly. icon_smile.gif

Regards, Jack.
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1202
Location: India

PostPosted: Sat Feb 28, 2004 9:32 am    Post subject: Re
Reply with quote

Hai,

Yes. It's exactly right Jack.

Quote:
i am in confusion about, how to mention the digits in comp-3 format.


Your Query is 126. hence I assumed it's unsigned positive.

In Comp-3 each digit occupies half-a-byte. Hence we need 1+1/2 bytes for 126. And also COMP-3 requires a half byte for sign digit. (Even if it's unsigned)

Hence totally we need 2 bytes.

Let's take 1, the equivalent 8421 code is: 0001
8421 code for 2 is: 0010
For 6 IT'S: 0110

Hence we get 0001 0010 0110

For Unsigned numeric the last nipple is: F
For Signed positive: C
For Negative: D

Equivalent 8421 code for F is : 1111

Hence our result is: 0001 0010 0110 1111

Is it Ok?
Back to top
View user's profile Send private message
philipraju
Warnings : 1

New User


Joined: 16 Apr 2006
Posts: 29

PostPosted: Sun Apr 16, 2006 12:47 pm    Post subject:
Reply with quote

hi,
im in small confusion in memory usage of comp,comp1,comp2.pls can any body explains by using same value for all.
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 Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm


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