Compaq COBOL AAQ2G1FTK User Manual

Page 557

Advertising
background image

Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration

B.4 Compaq COBOL and Compaq COBOL for OpenVMS VAX Behavior Differences

B.4.12 Arithmetic Operations

Several arithmetic operations differ in behavior between Compaq COBOL and
Compaq COBOL for OpenVMS VAX, depending upon your platform:

Results of numeric and integer Intrinsic Functions may differ from Compaq
COBOL for OpenVMS VAX or may be formatted differently by a DISPLAY
statement.

OpenVMS VAX and OpenVMS Alpha handle COMP-2 items differently. As
a result, DISPLAY of a USAGE COMP-2 data item low order digits may be
different from the low order digits of the data item from the DISPLAY with
Compaq COBOL for OpenVMS VAX on OpenVMS VAX.

Compaq COBOL issues the ALL_LOST (all digits lost) warning diagnostic in
different cases than Compaq COBOL for OpenVMS VAX.

When overflow occurs in an arithmetic statement without a SIZE ERROR
phrase and native arithmetic is used, the results are undefined. Compaq
COBOL for OpenVMS VAX often returns the low order digits of the true
result in such cases; Compaq COBOL does not. When standard arithmetic is
used, the results are unaltered.

The precision of intermediate results is different between Compaq COBOL
for OpenVMS VAX and Compaq COBOL. This is most noticeable in
COMPUTE operations involving a divide. If you need a specific precision
for an intermediate result, you should use a temporary variable with the
desired precision. For example:

COMPUTE D = (A / B) / C.

. . . could be written as

COMPUTE TMP1 = A / B.
COMPUTE D = TMP1 / C.

The precision to be used for the calculation A / B would be established by
your declaration of TMP1.

On Windows NT and Tru64 UNIX, the VAX floating point data types, F_
FLOAT, D_FLOAT, and G_FLOAT are not supported; whereas, on OpenVMS
Alpha systems, F_FLOAT and D_FLOAT are the defaults for floating point.
This difference potentially affects reading data files with COMP-1 and COMP-
2 keys built on OpenVMS Alpha systems. Also, any programs that check for
specific floating values rather than ranges of values may be impacted.

The results of numeric comparisons with Compaq COBOL for OpenVMS
VAX and Compaq COBOL are undefined with invalid decimal data. Compaq
COBOL includes the /CHECK=DECIMAL and

-check decimal

features to

do a more complete analysis of invalid decimal data. These options can be
particularly helpful when you are migrating programs to Compaq COBOL.

There is some inevitable incompatibility in results of arithmetic operations
involving large intermediate values, between Compaq COBOL and
Compaq COBOL for OpenVMS VAX. In Compaq COBOL, to minimize
the differences, you can use the /MATH_INTERMEDIATE=CIT3 qualifier
(or

-math_intermediate cit3

). With it, use the /ARITHMETIC=NATIVE

qualifier (or

-arithmetic native

), which is the default. (Specifying

/ARITHMETIC=STANDARD would force /MATH_INTERMEDIATE=CIT4.)

Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B–23

Advertising