Function
The SIGN clause specifies the position and the mode of representation of the operational sign for numeric data items.
Format
[SIGN IS] {LEADING | TRAILING} [SEPARATE CHARACTER]
Syntax rules
The SIGN clause may be specified only for a numeric data description entry whose PICTURE contains the character S, or a group item containing at least one such numeric data description entry.
The numeric data description entries to which the SIGN clause applies must be described, explicitly or implicitly, as USAGE IS DISPLAY.
If a SIGN clause is specified for either a group item or an elementary numeric item subordinate to a group item for which a SIGN clause is also specified, the SIGN clause of the subordinate group or numeric data item takes precedence for that item.
If the CODE-SET clause is specified, any signed numeric data description entries must be described with the SIGN IS SEPARATE clause.
The SIGN clause specifies the position and the mode of representation of the operational sign. If entered for a group item, it applies to each numeric data description entry subordinate to that group. The SIGN clause applies only to numeric data description entries whose PICTURE contains the character S; the S indicates the presence, but not the mode of representation, of the operational sign.
A numeric data description entry whose PICTURE contains the character S, but to which no SIGN clause applies, has an operational sign, but neither the representation nor, necessarily, the position of the operational sign is specified by the character S. (For representation of the operational sign see section "USAGE clause").
General rules
If the SEPARATE CHARACTER phrase is not present, then:
The letter S in a PICTURE character-string is not counted in determining the size of the item.
The operational sign will be presumed to be associated with the leading (or, respectively, trailing) digit position of the elementary numeric data item. The TRAILING phrase is taken as this compiler’s default value.
For the compiler, the operational sign is the half-byte C for positive and the half-byte D for negative.
If the SEPARATE CHARACTER phrase is present, then:
The letter S in a PICTURE character-string is counted in determining the size of the item.
The operational sign will be presumed to be the leading (or, respectively, trailing) character position of the elementary numeric data item; this character position is not a digit position.
The operational signs for positive and negative are the standard data format characters + and
-
, respectively.
Every numeric data description entry whose PICTURE character-string contains the character S is a signed numeric data description entry. If a SIGN clause applies to such an entry and conversion is necessary for purposes of computation or comparisons, conversion takes place automatically.
Example 7-27
IDENTIFICATION DIVISION. PROGRAM-ID. SIGNEXPL. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. TERMINAL IS T. DATA DIVISION. WORKING-STORAGE SECTION. 01 FIELD1 PIC S999 SIGN IS LEADING SEPARATE. 01 GROUP1 USAGE IS DISPLAY. 02 FIELD2 PIC S9(5) SIGN IS TRAILING SEPARATE. 02 FIELD3 PIC X(15). 02 FIELD4 PIC S99 SIGN IS LEADING. 01 FIELD5 PIC S9(9) SIGN IS TRAILING. PROCEDURE DIVISION. MAIN SECTION. P1. MOVE ZEROES TO FIELD1,FIELD2,FIELD3,FIELD4,FIELD5. MOVE 3 TO FIELD4. MOVE -2 TO FIELD5. MOVE FIELD4 TO FIELD2. MOVE FIELD2 TO FIELD3. MOVE FIELD5 TO FIELD4. DISPLAY "Field1 = " FIELD1 UPON T. DISPLAY "Field2 = " FIELD2 UPON T. DISPLAY "Field3 = " FIELD3 UPON T. DISPLAY "Field4 = " FIELD4 UPON T. DISPLAY "Field5 = " FIELD5 UPON T. STOP RUN.
The contents of all fields after each MOVE statement are shown below.
After the first MOVE statement:
FIELD1 | decimal |
| |||||||||||||||
hexadecimal |
| ||||||||||||||||
FIELD2 | decimal |
| |||||||||||||||
hexadecimal |
| ||||||||||||||||
FIELD3 | decimal |
| |||||||||||||||
hexadecimal |
| ||||||||||||||||
FIELD4 | decimal |
| |||||||||||||||
hexadecimal |
| ||||||||||||||||
FIELD5 | decimal |
| |||||||||||||||
hexadecimal |
|
After the second MOVE statement:
FIELD4 | decimal |
| ||
hexadecimal |
|
After the third MOVE statement:
FIELD5 | decimal |
| |||||||||
hexadecimal |
|
After the fourth MOVE statement:
FIELD2 | decimal |
| ||||||
hexadecimal |
|
After the fifth MOVE statement:
FIELD3 | decimal |
| |||||||||||||||
hexadecimal |
|
After the sixth MOVE statement:
FIELD4 | decimal |
| ||
hexadecimal |
|