Comp-3

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
logon2shashi
Member
Posts: 6
Joined: Wed Sep 02, 2015 6:24 pm

Comp-3

Post by logon2shashi » Wed Sep 02, 2015 6:39 pm

1. How to declare comp-3 for a value -3/2

2. If i have subscript as I[2], which will be picked from below 5 values
Also if my index is set to 4, i.e SET I=4, then which will be picked.

| A | B | C | D | E |

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Sep 02, 2015 6:51 pm

PACKED-DECIMAL PIC S9V9.

B. D.

Interview questions? You also need to know why, not just know the answers.

logon2shashi
Member
Posts: 6
Joined: Wed Sep 02, 2015 6:24 pm

Post by logon2shashi » Wed Sep 02, 2015 7:02 pm

Could you please explain me ?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Sep 02, 2015 10:37 pm

There are two ways to define a packed-decimal field. One is with COMP-3. Across different COBOL compilers, COMP-3 is not always packed-decimal. So, for new programs it is good to use PACKED-DECIMAL which is identical to using COMP-3, but is transportable to other compilers.

-3/2, so you need a signed number, which means the PICture string must start with an S. The field must contain an implied decimal-place (since the answer you need to hold is -1.5) so it needs a V. You need one digit before the decimal place, and one digit after.

So, PACKED-DECIMAL PIC S9V9.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others