usage of BINARY for arithmetic operations.



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

usage of BINARY for arithmetic operations.

Postby Lightning Lad » Thu Jan 21, 2010 8:39 pm

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?
Lightning Lad
 
Posts: 5
Joined: Thu Jan 21, 2010 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: usage of BINARY for arithmetic operations.

 

Re: usage of BINARY for arithmetic operations.

Postby Robert Sample » Thu Jan 21, 2010 8:41 pm

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

Re: usage of BINARY for arithmetic operations.

Postby chaat » Sat Jan 30, 2010 10:22 am

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.
chaat
 
Posts: 14
Joined: Sun Aug 16, 2009 11:07 pm
Location: St. Cloud, Minnesota
Has thanked: 0 time
Been thanked: 1 time

Re: usage of BINARY for arithmetic operations.

Postby dick scherrer » Sat Jan 30, 2010 10:48 am

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 :)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post