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
 

 

What does packed decimal digits means.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: What does packed decimal digits means.
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    Post subject: Re: What does packed decimal digits means.
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    Post subject:
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    Post subject: Re: What does packed decimal digits means.
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    Post subject: Re: What does packed decimal digits means.
Reply with quote

Hi,
You will get more clear ans from the following link
http://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    Post subject:
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    Post subject: Re: What does packed decimal digits means.
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    Post subject: Re: What does packed decimal digits means.
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    Post subject: Re: What does packed decimal digits means.
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    Post subject: Re: What does packed decimal digits means.
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    Post subject:
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    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 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
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm


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