How many bytes this type of variable will take?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How many bytes this type of variable will take?

Postby arya_starc » Tue Sep 13, 2016 3:20 pm

Hi

Can anybody tell me that how many bytes this variable will be take?
03 WS-TR-TXN-CODE PIC S9(04).
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

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

 

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

Postby Robert Sample » Tue Sep 13, 2016 3:30 pm

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.
Robert Sample
Global moderator
 
Posts: 3121
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 182 times

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

Postby arya_starc » Tue Sep 13, 2016 6:07 pm

then why 'S' is mentioned before 9. it can also be simply written as 03 WS-TR-TXN-CODE PIC 9(04).
is it?
arya_starc
 
Posts: 60
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 3 times
Been thanked: 0 time

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

Postby NicC » Tue Sep 13, 2016 6:15 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2531
Joined: Sun Jul 04, 2010 12:13 am
Location: Down on the pig farm
Has thanked: 4 times
Been thanked: 88 times

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

Postby Robert Sample » Tue Sep 13, 2016 6:40 pm

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 .
Robert Sample
Global moderator
 
Posts: 3121
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 182 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post