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

Diff between Packed decimal and binary decimal formats


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1210
Location: India

PostPosted: Fri Feb 20, 2004 2:32 pm
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
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: 1210
Location: India

PostPosted: Mon Feb 23, 2004 12:18 pm
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
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
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: 1210
Location: India

PostPosted: Sat Feb 28, 2004 9:32 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
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