Page 1 of 1

usage of BINARY for arithmetic operations.

PostPosted: Thu Jan 21, 2010 8:39 pm
by Lightning Lad
In my code I have declared loop counters as a packed decimal field


01 INDEX-FIELD.
03 P PIC S9(5) PACKED-DECIMAL VALUE 0.

Will it improve performance on a significant basis of the COBOL program in terms of CPU time etc., if i declare this field as BINARY?

Re: usage of BINARY for arithmetic operations.

PostPosted: Thu Jan 21, 2010 8:41 pm
by Robert Sample
Unless the field is being references tens (or hundreds) of millions of times in your code, no you will not see any significant improvement by converting to BINARY.

Re: usage of BINARY for arithmetic operations.

PostPosted: Sat Jan 30, 2010 10:22 am
by chaat
The name of the variables in the sample code suggest that this "counter" may be used as a subscript.

If that is the case, subscripts are perform much better if they are defined as binary fields.

ps. even better than subscripts is to use INDEX's to process arrays.

Chuck Haatvedt

when a programmer develops produces inefficient code when it would take no more time to code efficiently, they are doing a disservice to their employer.

Re: usage of BINARY for arithmetic operations.

PostPosted: Sat Jan 30, 2010 10:48 am
by dick scherrer
Hello and welcome to the forum,

While binary mibht be "better", please re-read closely what Robert has posted. . .
Unless the field is being references tens (or hundreds) of millions of times in your code, no you will not see any significant improvement by converting to BINARY.


With the newer, extremely more powerful processors, this is rarely a ocncern.

when a programmer develops produces inefficient code when it would take no more time to code efficiently, they are doing a disservice to their employer.
Agree completely :)