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
 

 

How COMP and COMP-3 values are stored

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

New User


Joined: 02 Mar 2007
Posts: 35
Location: Pennsylvania, US

PostPosted: Thu Mar 15, 2007 2:46 pm    Post subject: How COMP and COMP-3 values are stored
Reply with quote

Hi,

Can anyone tell me how COMP and COMP-3 values are stored? How storage bytes are calculated?
Back to top
View user's profile Send private message

rammraju

New User


Joined: 05 Mar 2005
Posts: 65
Location: Hyderabad

PostPosted: Thu Mar 15, 2007 3:12 pm    Post subject: Re: Clarify storage of COMP and COMP-3
Reply with quote

Comp stores data in binary format.
They occupy 2, 4, or 8 bytes of storage. If the PICTURE clause is signed, the leftmost bit is used as the sign. EX: A binary number with a PICTURE <=4 decimal digits occupies 2 bytes; 5 to 9 decimal digits occupies 4 bytes, 10 to 18 decimal digits occupies 8 bytes.

Comp-3 stores data in Packed decimal format
Packed-decimal items occupy 1 byte of storage for every 2 decimal digits you code in the PICTURE clause, except that the rightmost byte contains only one digit and the sign.

Hope this is clear
Back to top
View user's profile Send private message
naveen_amudalapelly
Warnings : 1

New User


Joined: 15 Oct 2004
Posts: 16

PostPosted: Thu Mar 15, 2007 3:14 pm    Post subject: Re: Clarify storage of COMP and COMP-3
Reply with quote

comp is a binary usage and while comp-3 is packed decimal.
comp value stroes as binary and comp-3 store as hexa decimal format
For example if your number is +100, it stores hex 0C in the
last byte, hex 1C if your number is 101, hex 1D if the number is -101, hex 2D if the number is -102 etc
Back to top
View user's profile Send private message
cooldebi

New User


Joined: 19 Apr 2006
Posts: 18
Location: mumbai

PostPosted: Thu Mar 15, 2007 4:47 pm    Post subject: Re: Clarify storage of COMP and COMP-3
Reply with quote

Storage is calculated as:
let 01 WS-x PIC S9(x) usage is comp.
let 01 WS-x PIC S9(x) usage is comp-3
for COMP --> no of bytes = x/2 (usually x is 2,4,8,16)
for COMP-3 --> no of bytes = |(x/2+1/2)| as 1/2 is required for storing sign

suppose u want to store 12 --> in a variable PIC 9(2) usage is comp.

Internally it will be stored as 00001100 in 1 byte (binary representation).

suppose u want to store 12 --> in a variable PIC 9(2) usage is comp-3.

Internally it will be stored as 0001 0010 [quote]1111 0000 (Hexadecimal representation)in 2 bytes.

underlined characters represents the sign nibble for comp-3.. 1111

cheers
Back to top
View user's profile Send private message
Shobana Bhaskar

New User


Joined: 02 Mar 2007
Posts: 35
Location: Pennsylvania, US

PostPosted: Fri Mar 16, 2007 1:13 pm    Post subject: Re: How COMP and COMP-3 values are stored
Reply with quote

Thanks a lot friends... icon_smile.gif
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 Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm


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