7 using the arithmetic statements – Compaq COBOL AAQ2G1FTK User Manual

Page 103

Advertising
background image

Handling Numeric Data

2.6 Using the MOVE Statement

Table 2–3 (Cont.) Numeric Editing

FLD-B

TOTAL-AMT

PICTURE String

Contents After MOVE

-6543^21

$,$$$,$$$.99DB

$6,543.21DB

1

1

The output includes DB if a negative value is moved.

The currency symbol ($ or other currency sign) and the editing sign control
symbols (+ and –) are the only floating symbols. To float a symbol, enter a string
of two or more occurrences of that symbol, one for each character position over
which you want the symbol to float.

2.6.3 Subscripted Moves

Any item (other than a data item that is not subordinate to an OCCURS clause)
of a MOVE statement can be subscripted, and the referenced item can be used to
subscript another name in the same statement.

For additional information, see Section 3.6.4, Subscripted Moves in Chapter 3,
Handling Nonnumeric Data.

2.6.4 Common Move Errors

Programmers most commonly make the following errors when writing MOVE
statements:

Placing an incorrect number of replacement characters in a numeric edited
item

Moving nonnumeric data into numeric items with group moves

Trying to float the currency sign ( $ ) or plus ( + ) insertion characters past
the decimal point to force zero values to appear as .00 instead of spaces (use
$$.99 or .99)

Forgetting that the currency sign ( $ ), plus sign ( + ), minus sign ( – ), CR,
or DB insertion characters require one or two additional positions on the
leftmost end that cannot be replaced by a digit (unlike the asterisk ( * )
insertion character, which can be completely replaced)

2.7 Using the Arithmetic Statements

The Compaq COBOL arithmetic statements allow programs to perform arithmetic
operations on numeric data. Large values present various problems, and COBOL
command qualifiers can help resolve or mitigate them. The following sections
discuss these topics.

2.7.1 Temporary Work Items

Compaq COBOL allows numeric items and literals with up to 31 decimal digits
(see Appendix A for specific limits). Hence it is quite easy to construct arithmetic
expressions that produce more than 31 digits.

Most forms of the arithmetic statements perform their operations in temporary
work locations, then move the results to the receiving items, aligning the
decimal points and truncating or zero-filling the resultant values. The actual
size of a temporary work item varies for each statement; it is determined at
compile time, based on the sizes of the operands used by the statement and the

Handling Numeric Data 2–9

Advertising