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

What does packed decimal digits means.


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

New User


Joined: 05 May 2005
Posts: 50

PostPosted: Tue Jun 07, 2005 8:52 am
Reply with quote

Hi,
can anybody plz tell me:
In cobol programming if we define a numeric data in comp-3 it is stored interenally as packed decimal digits.is it right,then what does packed decimal digits means.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Tue Jun 07, 2005 2:28 pm
Reply with quote

Yes u are correct. One to 16 bytes may be used to store a sequence of decimal digits representing an arithmetic value. A pattern of four bits is defined for each decimal digit. Since a byte consists of eight bits, upto two decimal digits may be packed into one byte and one half of a byte is reserved for tyhe sign + or - of the number. Eg. to represent +5, one byte is needed which is denoted as 5+ where 5 holds the binary value 0101 and + holds the binary bit pattern value 1100.
Back to top
View user's profile Send private message
senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 16

PostPosted: Wed Jun 08, 2005 4:44 pm
Reply with quote

packed decimal means hexa decimal value.
Back to top
View user's profile Send private message
Sangram

New User


Joined: 08 Jun 2005
Posts: 7

PostPosted: Wed Jun 08, 2005 5:00 pm
Reply with quote

[color=darkblue]Packed decimal is nothing but the hexadecimal equivalent of the data that you have entered. It will not be visible when the file having packed decimal data is opened in edit mode unless you use a HEX ON. It is used to provide optimum storage. A variable with PIC X(5) COMP-3 will occupy only 3 bytes in the storage memory.
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Wed Jun 08, 2005 5:14 pm
Reply with quote

Hi,
You will get more clear ans from the following link
www.ibmmainframes.com/viewtopic.php?t=3147&highlight=comp3
Back to top
View user's profile Send private message
senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 16

PostPosted: Thu Jun 09, 2005 11:57 am
Reply with quote

Hi sangram,

Alphanumeric picture clause is not possible in comp-3 usage. As per your example, you mention that it takes 3 bytes storage. it's wrong. it takes 4 bytes because 3 bytes for value and one byte for sign. If you feel and wrong in my answer, please send me
Back to top
View user's profile Send private message
frame_kan

New User


Joined: 03 Jun 2005
Posts: 5

PostPosted: Thu Jun 09, 2005 12:20 pm
Reply with quote

Hi

I think it will take 3 bytes 2.5 +.5 .As far as alphanumeric picture clause is concern i am not sure whether we can define it or not

Frame
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Thu Jun 09, 2005 12:31 pm
Reply with quote

It is (n+1)/2 for odd digit and (n/2 + 1) for even digit. Try this out. You will get exactly how many bytes does the variable occupies. If any alterations in my answer, correct it.
Back to top
View user's profile Send private message
Sangram

New User


Joined: 08 Jun 2005
Posts: 7

PostPosted: Thu Jun 09, 2005 12:38 pm
Reply with quote

Hi Senthilkumar,

COMP 3 usage is usually done for signed integers. Thats the most common and optimum use of comp 3 . The storage space for COMP 3 is calculated by using the formula (n+1)/2 where 'n' stands for the actual size of the variable. For e.g. - a variable of PIC X(5) COMP-3 will take 3 bytes of storage where the 5 bytes of the variable will be stored in 2.5 bytes of actual storage and the sign will be stored in 0.5 bytes of actual storage. The sign is always stored in the last half byte of the actual storage. If you need further info, drop in a reply.
Back to top
View user's profile Send private message
worthy2005

New User


Joined: 09 Mar 2005
Posts: 17
Location: Shanghai,China

PostPosted: Tue Jul 19, 2005 9:36 pm
Reply with quote

j_prameela2000 wrote:
Eg. to represent +5, one byte is needed which is denoted as 5+ where 5 holds the binary value 0101 and + holds the binary bit pattern value 1100.


But how about -5? '+' represents 1100, but '-' represents what? Thanx!
Back to top
View user's profile Send private message
thanooz

New User


Joined: 28 Jun 2005
Posts: 99

PostPosted: Tue Jul 19, 2005 9:58 pm
Reply with quote

hi

comp-3 is used store data in packed decimal format.it is hexa decimal storage.the n/2 bytes for actuval value 1/2 byte for sign representation


if its sign is positive last halfbyte have hexa c,negative d,unsigned f .


thanooz
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 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
No new posts Want to mask Middle 8 Digits of Debit... COBOL Programming 3
Search our Forums:

Back to Top