View previous topic :: View next topic
|
Author |
Message |
santosh100678
New User
Joined: 21 Sep 2009 Posts: 55 Location: Kolkatta
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
TS70363
New User
Joined: 07 Apr 2010 Posts: 94 Location: Bangalore, India
|
|
|
|
Please refer to this five page document explaining Zone-Decimal, COMP, COMP-1, COMP-2 and COMP-3. |
|
Back to top |
|
|
|