Handling Numeric Data
2.6 Using the MOVE Statement
If the sending item has fewer digit positions than the receiving item, the move
operation supplies zeros for all unfilled digit positions.
01
TOTAL-AMT PIC 999V99 VALUE ZEROS.
.
.
.
MOVE 1 TO TOTAL-AMT.
Before execution:
000^00
After execution:
001^00
The following statements produce the same results:
MOVE 001.00 TO TOTAL-AMT.
MOVE "1" TO TOTAL-AMT.
Consider the following two MOVE statements and their truncating and zero-
filling effects:
Statement
TOTAL-AMT After Execution
MOVE 00100 TO TOTAL-AMT
100^00
MOVE "00100" TO TOTAL-AMT
100^00
Literals with leading or trailing zeros have no advantage in space or execution
speed in Compaq COBOL, and the zeros are often lost by decimal point
alignment.
The MOVE statement’s receiving item dictates how the sign will be moved. When
the receiving item is a signed numeric item, the sign from the sending item is
placed in it. If the sending item is unsigned, and the receiving item is signed, a
positive sign is placed in the receiving item. If the sending item is signed and the
receiving item is unsigned, the absolute value of the sending item is moved to the
receiving item.
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:
Z
B
Asterisk ( * )
Period ( . )
Plus sign ( + )
Minus sign ( – )
CR
DB
Currency symbol
Slash ( / )
Comma ( , )
Zero ( 0 )
Handling Numeric Data 2–7
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......