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

Regarding storage of Comp and Comp-3


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

New User


Joined: 21 Sep 2009
Posts: 55
Location: Kolkatta

PostPosted: Sun May 02, 2010 6:37 pm
Reply with quote

Hi,

Could you please guide me regarding storage of Comp and Comp-3

according to theory i know
Comp will take internally n/2 bites
and Comp-3 will take internally n/2+1 bytes

My question is

suppose i have 01 a pic S9(4) comp which will take 2 bytes
01 a pic S9(5) comp which will also take 2 bytes
so which one take more digit in their storage

and other samething with comp-3
01 a Pic s9(6) Comp-3 will take 4 bytes
01 a pic S9(7) comp-3 will take 4 bytes

which one store more.

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sun May 02, 2010 7:05 pm
Reply with quote

Quote:
according to theory i know
Comp will take internally n/2 bites
and Comp-3 will take internally n/2+1 bytes
You know wrong.

There is a link to manuals at the top of the page. Click on it, find the COBOL Language Reference manual, and read up on internal storage format of variables. You will discover, if you read long enough, that COMP variables can be 2 bytes, or 4 bytes, or 8 bytes -- that is all.

Furthermore, contrary to your post, PIC S9(05) COMP will NOT take 2 bytes.

Do not confuse the internal storage with the picture definition. A PIC S9(6) COMP-3 variable can store values from -999999 to +999999 whereas a PIC S9(07) COMP-3 can store values from -9999999 to +9999999 even though they both take 4 bytes. You can find out in the manuals just why.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sun May 02, 2010 7:13 pm
Reply with quote

S9(4) comp is a two byte field such as X'0000'.
Max four digit decimal value is 9999=X'27F0'
Max positive binary value is X'8FFF'=36863

S9(7) comp-3 is a four byte field such as X'0000000C'.
Max value is 9999999.
S9(6) comp-3 is a four byte field such as X'n000000C' where 'n' might be ignore/suppressed in certian COBOL situations.
Max value is 999999.

When I went to programming school, the first lessons of Computers 101 was how the computer stored information, hex, octal or binary.
The second was how the operating system stored data, binary, packed decimal or zoned decimal floating too, but I kinda sleep through that...grin...).
[suppresed by moderator]
...
[/suppresed by moderator]
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon May 03, 2010 3:23 pm
Reply with quote

Please refer to this five page document explaining Zone-Decimal, COMP, COMP-1, COMP-2 and COMP-3.
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 CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts CICS vs LE: STORAGE option CICS 0
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Insufficient Storage ABENDS & Debugging 7
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top