Which is better Pic S9(9) or using -9(9)?
Which is better Pic S9(9) or using -9(9)?
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?
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?
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Which is better Pic S9(9) or using -9(9)?
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)?
Robert,
By this
Thanks,
By this
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?The answer to your question partly depends upon what you mean by "better for calculation".
Thanks,
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Which is better Pic S9(9) or using -9(9)?
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.
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)?
Quite an informative Thread. Thanks Robert for sharing your views.
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