Page 1 of 1

Basic Question

PostPosted: Thu Mar 10, 2011 5:47 pm
by cooldude14344
Guys

Please let me know how much size the below variable occupy?

PERCENT PIC 9(5)V999.

I would like to declare it as PIC 9(4)V(4). - will that have the same size?

Re: Basic Question

PostPosted: Thu Mar 10, 2011 6:08 pm
by Robert Sample
Your question cannot be asnwered as stated. If PERCENT is USAGE DISPLAY, the variable will use 8 bytes. If PERCENT is USAGE COMP, the variable will use 4 bytes. If PERCENT is USAGE COMP-3, the variable will use 5 bytes.

Moving the implied decimal point will NOT change the length of the variable. It may, however, cause you severe problems unless ALL the data is converted to the new format at one time. Since the decimal point is only implied and not actually present, 12345678 would be interepreted as 12345.678 with one PIC and 1234.5678 with the other PIC. These values are not the same, even though the underlying representation (12345678) did not change.

Re: Basic Question

PostPosted: Thu Mar 10, 2011 7:34 pm
by BillyBoyo
Easiest way to check is to put both in a program, compile, and look at the DMAP generated - always works.

If it is some sort of training question, check out the diffence between storage allocation for 77 level (stuck next to the previous item) and 01 level where each is "lined up" (double-word boundary, or is it a full-word - help me out someone) where you will have some "slack" bytes (storage which is taken up, but which isn't actually used for anything). Again, try some, look at the DMAP and try to understand the difference in the locations.

Re: Basic Question

PostPosted: Fri Mar 11, 2011 3:10 am
by cooldude14344
Thanks guys

Re: Basic Question

PostPosted: Sun Mar 13, 2011 11:15 pm
by Quasar
Cooldude -

Both the PICTURE Specifications occupy the same storage space(8 Bytes) in COBOL. There's difference however, in the position of the Assumed decimal point.

Thank you very much.