Joined: 08 Jun 2007 Posts: 71 Location: Zoetermeer, the Netherlands
I guess COMP-5 is same as comp-2
COMP-5 stands for "binary native". On the mainframe this is not really an issue. On ohter platforms, however, there are processor architectures representing integers in a different way (http://en.wikipedia.org/wiki/Endianness). All those computers can run COBOL so sometimes the cobol compilers forces those binary-integers to behave in a standard way (comp-4). This might be sub-optimal for calculations. Specifiying COMP-5 allows native represention and optimal performance for calculations (comp-3 does not perform at all outside the mainframe!) .
So, when you want to produce portable code, always use comp-5 for your calculations.
I've also used this in the past to test at execution time to determine on which machine the program ran:
03 B-I-G-endian value +0004 pic S9(4) comp-5.
03 litle-endian value +1024 pic S9(4) comp-5.
display "this is the AIX (powerPC)"
display "this is a PC (intel inside!)"
display "how the *beep* do you run this program?"
Those days I was coding & testing on windows (Micro Focus NetExpress) and the target machine was a R6000 (Micro Focus ServerExpress).