Optimizing Your Compaq COBOL Program
15.3 Using COMP Data Items for Speed
Precision Not Reduced by Conversion to COMP
The data types usually employed for COBOL data items are summarized below:
Usage Data Type
COMP, BINARY,
COMP-5, COMP-X
Binary
COMP-1 F-Float (compiled with /FLOAT=D_FLOAT
or /FLOAT=G_FLOAT)
S-Float (compiled with /FLOAT=IEEE_FLOAT)
COMP-2 D-Float (compiled with /FLOAT=D_FLOAT)
G-Float (compiled with /FLOAT=G_FLOAT)
T-Float (compiled with /FLOAT=IEEE_FLOAT)
COMP-3,
PACKED-DECIMAL
Packed-decimal
DISPLAY Text or decimal
On Tru64 UNIX systems, the F_FLOAT, D_FLOAT and G_FLOAT data types are
not supported. ♦
Operations on COMP-1 and COMP-2 data items are fast. However, it is not
recommended that you convert data items to COMP-1 or COMP-2, because you
could lose precision. Floating-point numbers are approximations using a scientific
notation relative to powers of two. A COMP-1 operand gives approximately 7
decimal digits of precision, a COMP-2 approximately 15; either often represents a
value less precisely than the other data types, which are fixed point.
The semantics of COMP (BINARY, COMP-5, COMP-X), COMP-3 (PACKED-
DECIMAL), and DISPLAY operands are the same: each can be scaled (except
for COMP-5 and COMP-X) and signed, and can hold up to 18 decimal digits.
Therefore, converting existing programs from COMP-3 or DISPLAY to COMP
will yield results that are no less accurate or precise. The only effect on operands
is the method of storage; and the primary effect on operations is improved
performance.
Because changing the data type changes the way data is stored, you may not be
able to change the data type of items that participate in a REDEFINES or that
are elements of file record structures.
Tools That Can Help You Decide Whether to Convert a Program
Compaq does not recommend a massive conversion of all source programs to
use COMP operands. Most existing COBOL programs perform very well, and
conversions of old programs can be expensive. The following tools can help you
decide which programs would run significantly faster if converted, and to discover
program interdependencies:
PCA
On OpenVMS, the Performance and Coverage Analyzer (PCA) can target specific
areas of programs that require large amounts of CPU time. If 80 percent of the
processing time is used by 20 percent of the COBOL routines, you may benefit
from converting only these routines to use COMP.
15–6 Optimizing Your Compaq COBOL Program