My confusion over this could be causing my bug. I'll be grately deepful for the correct answer.
It would be 12 as S takes up no data. Although when displayed, the or - will be trailing. For example S9(3) would display 123- given that the value you declare is negative. Hope this helps. I myself am just learning COBOL myself. If someone could just double check me.
Yes, Moto - it's 12.
Cobol has a "length of" operator you can use to find the length of any field - see below. For group items, the Editor tooltips also include the length of the item - though unfortunately not for elementary items like pic s9(12).
01 a pic s9(12).
display length a
Yes, as previously posted, the size is 12. Another way to confirm this is with a datamap in the listing, that is, when the LIST() and DATAMAP directives are specified for the compilation. Here's the results for some numbers without and with the separate option for the sign:
8 working-storage section.
9 01 mynumber-01a pic s9(12).
10 01 mynumber-01b pic s9(12) trailing.
11 01 mynumber-01c pic s9(12) leading.
12 01 mynumber-01d pic s9(12) trailing separate.
13 01 mynumber-01e pic s9(12) leading separate.
15 procedure division.
18 end program mynumber01.
* Program-Id : MYNUMBER01
* Line Data Name Address Size Attributes
* 000009 MYNUMBER-01A. . . . . . . . . . 0000000080 00000012 WS E Display
* 000010 MYNUMBER-01B. . . . . . . . . . 0000000096 00000012 WS E Display
* 000011 MYNUMBER-01C. . . . . . . . . . 0000000112 00000012 WS E Display
* 000012 MYNUMBER-01D. . . . . . . . . . 0000000128 00000013 WS E Display
* 000013 MYNUMBER-01E. . . . . . . . . . 0000000144 00000013 WS E Display