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

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

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

Post 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?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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).
Sandy
Registered Member
Posts: 51
Joined: Sat Jun 15, 2013 1:07 pm

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

Post 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,
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
User avatar
DB2 Guy
Forum Moderator
Forum Moderator
Posts: 120
Joined: Sun Apr 21, 2013 8:25 pm
India

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

Post by DB2 Guy »

Quite an informative Thread. Thanks Robert for sharing your views.
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

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

Post by Dino »

Thanks Robert... :)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”