Joined: 06 Jun 2008 Posts: 8212 Location: Dubuque, Iowa, USA
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.
Joined: 18 Jul 2007 Posts: 2150 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]