Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us