Page 1 of 1

How many bytes this type of variable will take?

PostPosted: Tue Sep 13, 2016 3:20 pm
by arya_starc
Hi

Can anybody tell me that how many bytes this variable will be take?
03 WS-TR-TXN-CODE PIC S9(04).

Re: How many bytes this type of variable will take?

PostPosted: Tue Sep 13, 2016 3:30 pm
by Robert Sample
4 bytes of course. The internal representation of values is explained at length in the manual.

If the variable was COMP it would be 2 bytes and for COMP-3 it would be 3 bytes.

Re: How many bytes this type of variable will take?

PostPosted: Tue Sep 13, 2016 6:07 pm
by arya_starc
then why 'S' is mentioned before 9. it can also be simply written as 03 WS-TR-TXN-CODE PIC 9(04).
is it?

Re: How many bytes this type of variable will take?

PostPosted: Tue Sep 13, 2016 6:15 pm
by NicC
It is all explained in the manual. The manual has been produced so that you can read it to find out about all these things. If somethinjg is not clear in the manual then ask questions.

Re: How many bytes this type of variable will take?

PostPosted: Tue Sep 13, 2016 6:40 pm
by Robert Sample
Yes, it can be written with or without the S. Without the S, the value MUST be zero or positive; with the S, the value can be zero or positive or negative. The internal representation of the sign does not require another byte for USAGE DISPLAY data.

You need to spend some time in the Enterprise COBOL Programming Guide manual http://publibfp.boulder.ibm.com/epubs/pdf/igy6pg10.pdf and pay particular attention to page 53 of the V6.1 manual, which is a table titled Examples: numeric data and internal representation .