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
 

 

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: 7936
Location: Bellevue, IA

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: 93
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 Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts How storage is calculated for AN-Edit... Raghu navaikulam COBOL Programming 2 Wed Mar 09, 2016 3:51 pm


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