Page 1 of 1

Which is better Pic S9(9) or using -9(9)?

Posted: Fri Jul 05, 2013 7:23 pm
by Dino
Hi,

Which one is better for calculation - Pic S9(9) or -9(9) ? O there is no difference?

For reporting purposes we use -9(9), however for computation which is better?

Re: Which is better Pic S9(9) or using -9(9)?

Posted: Fri Jul 05, 2013 8:03 pm
by Robert Sample
The answer to your question partly depends upon what you mean by "better for calculation". For general calculations, using COMP-3 (packed decimal) is usually better than DISPLAY (zoned decimal). For some calculations, using COMP (binary) will be better than COMP-3 or DISPLAY. The -9(9) is called a numeric edited field and the sign will be converted during the calculations to a positive value (if the result variable is unsigned) or calculated per the calculations (if the result variable is signed).

Re: Which is better Pic S9(9) or using -9(9)?

Posted: Sat Jul 06, 2013 12:12 pm
by Sandy
Robert,

By this
The answer to your question partly depends upon what you mean by "better for calculation".
are you trying to say that if the calculations involved are 'scientific' or 'in general' , as you said? I mean, will that really make a difference?

Thanks,

Re: Which is better Pic S9(9) or using -9(9)?

Posted: Sat Jul 06, 2013 6:31 pm
by Robert Sample
In general, anyone concerned about performance in this day of executing tens of millions to hundreds of millions of COBOL statements per second of CPU time is extremely misguided -- except for the one case where the program is already in production and not meeting batch window requirements. So the whole "better for" request is somewhat suspect to start with.

That said, in general using packed decimal (COMP-3) will in most cases provide the best performance. If the calculation is for an index then it is possible that using binary (COMP or COMP-5 preferably) will yield better performance. In either case, the only way to see the difference will be through running BILLIONS of calculations. Most programs could use DISPLAY even for calculations and never see any real performance hit.

Re: Which is better Pic S9(9) or using -9(9)?

Posted: Mon Jul 08, 2013 11:25 am
by DB2 Guy
Quite an informative Thread. Thanks Robert for sharing your views.

Re: Which is better Pic S9(9) or using -9(9)?

Posted: Sun Jul 28, 2013 5:25 pm
by Dino
Thanks Robert... :)