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
 
Regarding storage of Comp and Comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Regarding storage of Comp and Comp-3
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: 8280
Location: Dubuque, Iowa, USA

PostPosted: Sun May 02, 2010 7:05 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sun May 02, 2010 7:13 pm    Post subject:
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    Post subject: Reply to: Regarding storage of Comp and Comp-3
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    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 INSUFFICIENT VIRTUAL STORAGE!! Vignesh Sid SYNCSORT 1 Thu Dec 28, 2017 3:45 pm
No new posts COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am

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