Handling Numeric Data
2.7 Using the Arithmetic Statements
arithmetic operation being performed. Should the temporary work item exceed
the maximum size, truncation occurs. The maximum temporary work item size is
31 digits for standard arithmetic and for native CIT4 arithmetic, and is 38 digits
for some operations using native float or native CIT3.
Programs should not arbitrarily specify sizes significantly larger than the values
actually anticipated for the lifetime of the application. Although the generous
limits in Compaq COBOL are useful for many applications, specifying 31 digits
when 12 would suffice, for example, is likely to add extra processing cycles and
complexity that is wasteful.
2.7.2 Standard and Native Arithmetic
Compaq COBOL supports two modes of arithmetic, standard and native.
Standard arithmetic is preferable for greater precision with large values and
for compatibility with other standard implementations of COBOL. These
considerations are sometimes overridden by the need for compatibility with
earlier versions of Compaq COBOL or for compatibility with Compaq COBOL for
OpenVMS VAX, in which case native arithmetic is the appropriate mode.
Native arithmetic has three submodes: FLOAT, CIT3, and CIT4. (CIT stands for
COBOL Intermediate Temporary).
You can specify the arithmetic mode and submode with the two COBOL
command-line qualifiers /ARITHMETIC and /MATH_INTERMEDIATE. The
use of these qualifiers is described in this section.
2.7.2.1 Using the /MATH_INTERMEDIATE Qualifier
You can specify the intermediate data type to be used when the result of an
arithmetic operation cannot be represented exactly. This data type affects the
truncation of the intermediate result and the consequent precision. It also affects
compatibility of arithmetic results with previous versions of COBOL and other
implementations of COBOL.
The three options of the /MATH_INTERMEDIATE (or
-math_intermediate
)
qualifier are FLOAT (the default), CIT3, and CIT4, as follows:
FLOAT
Selects double-precision binary floating-point for the intermediate data type.
Intermediate values are truncated to the most significant 53 bits, with an 11-bit
exponent, resulting in approximately 15 decimal digits of precision. FLOAT is
the default, and it provides for compatibility with earlier versions of Compaq
COBOL, but not with Compaq COBOL for OpenVMS VAX. FLOAT has been
used since Version 1.0 of Compaq COBOL.
CIT3
Selects Cobol Intermediate Temporary (design 3) for the intermediate data
type. Intermediate values are truncated to the most significant 18 decimal
digits, with a 2-digit exponent. CIT3 provides for increased compatibility with
Compaq COBOL for OpenVMS VAX; even with CIT3, however, there are still
some differences, which are described in Section B.4.12.
CIT4
Selects Cobol Intermediate Temporary (design 4) for the intermediate data
type. Intermediate values are truncated to the most significant 32 decimal
digits, with a 2-digit exponent. CIT4 has the greatest compatibility with the
draft ANSI Standard. CIT4 is the option of choice for greatest precision and for
conformance to future standards and compatibility with other implementations
of COBOL. CIT4 is strongly recommended for programs that use numeric items
with more than 18 digits or that have complicated expressions.
In addition to the precision difference, CIT4 arithmetic has the same differences
and restrictions as shown in Section B.4.12 for CIT3 arithmetic.
2–10 Handling Numeric Data
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......