Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Choosing efficient computational data items

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sachinji84

New User


Joined: 13 Dec 2007
Posts: 14
Location: india

PostPosted: Fri Feb 13, 2015 8:39 am    Post subject: Choosing efficient computational data items
Reply with quote

Hi,

I have been asked ;
for optimum storage points of view and for faster performance from below options which one is best;

1. PIC 9(4) COMP-3
2. PIC 9(5)
3. PIC S9(5) COMP
4. PIC S9(5) COMP-3

please assist to get the correct answer.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7936
Location: Bellevue, IA

PostPosted: Fri Feb 13, 2015 9:13 am    Post subject:
Reply with quote

Unless your program is doing BILLIONS to TENS OF BILLIONS of arithmetic operations, none of them will make any noticeable difference in CPU time or elapsed time. However, in general COMP-3 and COMP are preferred for mathematical operations (depending upon the precise operations being used). From the Enterprise COBOL Programming Guide manual:
Quote:
8.1.2.1 Choosing efficient computational data items




When you use a data item mainly for arithmetic or as a subscript, code USAGE BINARY on the data description entry for the item. The operations for manipulating binary data are faster than those for manipulating decimal data. However, if a fixed-point arithmetic statement has intermediate results with a large precision (number of significant digits), the compiler uses decimal arithmetic anyway, after converting the operands to packed-decimal form. For fixed-point arithmetic statements, the compiler normally uses binary arithmetic for simple computations with binary operands if the precision is eight or fewer digits. Above 18 digits, the compiler always uses decimal arithmetic. With a precision of nine to 18 digits, the compiler uses either form. To produce the most efficient code for a BINARY data item, ensure that it has:
A sign (an S in its PICTURE clause)
Eight or fewer digits


For a data item that is larger than eight digits or is used with DISPLAY | or NATIONAL data items, use PACKED-DECIMAL. The code generated for | PACKED-DECIMAL data items can be as fast as that for BINARY data items in some cases, especially if the statement is complicated or specifies rounding. To produce the most efficient code for a PACKED-DECIMAL data item, ensure that it has:
A sign (an S in its PICTURE clause)
An odd number of digits (9s in the PICTURE clause), so that it occupies an exact number of bytes without a half byte left over
15 or fewer digits in the PICTURE specification to avoid using library routines for multiplication and division
So your question does not have any ONE correct answer -- COMP or COMP-3 will be better, depending.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us