HP OpenVMS Systems Documentation

Content starts here

User Manual

Previous Contents Index

2.6.2 Elementary Numeric-Edited Moves

An elementary numeric move to a numeric-edited receiving item is considered an elementary numeric-edited move. The sending item of an elementary numeric-edited move can be numeric, numeric-edited, or alphanumeric. When the sending item is numeric-edited, de-editing is applied to establish the item's unedited numeric value, which may be signed; then the unedited numeric value is moved to the receiving field. Alphanumeric sending items in numeric-edited moves are considered unsigned DISPLAY usage integers.

A numeric-edited item PICTURE can contain 9, V, and P, but to qualify as numeric-edited, it must also contain one or more of the following editing symbols:

Asterisk (*)
Period (.)
Plus sign (+)
Minus sign (--)
Currency symbol
Slash (/)
Comma (,)
Zero (0)

For a complete description of these symbols, refer to the HP COBOL Reference Manual.

The numeric-edited move operation first converts the sending item to DISPLAY usage and aligns both items on their decimal point locations. The sending item is truncated or zero-filled until it has the same number of digit positions on both sides of the decimal point as the receiving item. The operation then moves the sending item to the receiving item, following the HP COBOL editing rules.

The rules allow the numeric-edited move operation to perform any of the following editing functions:

  • Replace leading zeros with either spaces or asterisks.
  • Float a currency sign and a plus or minus sign through suppressed zeros, inserting the sign at either end of the item.
  • Insert zeros, spaces, slashes, and/or the symbols CR or DB.
  • Insert commas and a decimal point (or decimal points and a comma if DECIMAL-POINT IS COMMA).

Table 2-3 illustrates several of these functions, which are invoked by the statement:


Assume that FLD-B is described as S9999V99. Note that the caret (^) indicates an assumed decimal point in Table 2-3. In all but two of the examples, the sign of FLD-B is leading separate. Trailing overpunch signs (the sign of the number encoded into the rightmost digit) are used in the other two FLD-B data examples.

Table 2-3 Numeric Editing
  PICTURE String Contents After MOVE
+0023^00 ZZZZ.99 23.00
-0023^00 ZZZZ.99 23.00
0085^9P ++++.99 -85.97
+1234^00 Z,ZZZ.99 1,234.00
+0012^34 $,$$$.99 $12.34
+0000^34 $,$$9.99 $0.34
+1234^00 $$,$$$.99 $1,234.00
+0012^34 $$9,999.99 $0,012.34
+0012^34 $$$$,$$$.99 $12.34
+0000^00 $$$,$$$.$$  
0012^3M ++++.99 -12.34
+0012^34 $***,***.99 $*****12.34
+1234^56 Z,ZZZ.99+ 1,234.56+
-6543^21 $,$$$,$$$.99DB $6,543.21DB 1

1The 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 HP 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

HP COBOL allows numeric items and literals with up to 31 decimal digits on Alpha and I64, and up to 18 decimal digits on VAX. (See Section 2.7.2 for more specific information.) It is quite easy to construct arithmetic expressions that produce too many 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 (also called an intermediate result item) varies for each statement; it is determined at compile time, based on the sizes of the operands used by the statement and the arithmetic operation being performed. Should the temporary work item exceed the maximum size, truncation occurs.

On Alpha and I64 systems, 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. <>

On VAX systems, the situation is different. The temporary work item has two forms, a scaled integer form and a software floating-point form. The scaled integer form has a maximum size of 31 numeric digits for a program compiled with the /INSTRUCTION_SET = DECIMAL_STRING or GENERIC qualifier, and a maximum of 38 digits for /INSTRUCTION_SET = NODECIMAL_STRING. When the compiler determines that the size of the intermediate result exceeds the maximum scaled integer size, it uses a software floating-point intermediate item and keeps the most significant 18 digits (for all settings of the /INSTRUCTION_SET qualifier). <>

Programs should not arbitrarily specify sizes significantly larger than the values actually anticipated for the lifetime of the application. Although the generous limits in HP COBOL are useful for many applications, specifying many more digits than needed is likely to add extra processing cycles and complexity that is wasteful.

Previous Next Contents Index