Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

SIGN clause

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

  1. 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.

  2. The numeric data description entries to which the SIGN clause applies must be described, explicitly or implicitly, as USAGE IS DISPLAY.

  3. 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.

  4. If the CODE-SET clause is specified, any signed numeric data description entries must be described with the SIGN IS SEPARATE clause.

  5. 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.

  6. 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

  1. If the SEPARATE CHARACTER phrase is not present, then:

    1. The letter S in a PICTURE character-string is not counted in determining the size of the item.

    2. 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.

    3. For the compiler, the operational sign is the half-byte C for positive and the half-byte D for negative.

  2. If the SEPARATE CHARACTER phrase is present, then:

    1. The letter S in a PICTURE character-string is counted in determining the size of the item.

    2. 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.

    3. The operational signs for positive and negative are the standard data format characters + and -, respectively.

  3. 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

+

0

0

0

hexadecimal

4E

F0

F0

F0

FIELD2

decimal

0

0

0

0

0

+


hexadecimal

F0

F0

F0

F0

F0

4E

FIELD3

decimal

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0


hexadecimal

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

F0

FIELD4

decimal

 0+

 0

hexadecimal

C0

F0

FIELD5

decimal

 0

 0

 0

 0

 0

 0

 0

 0

0+

hexadecimal

F0

F0

F0

F0

F0

F0

F0

F0

C0


After the second MOVE statement:

FIELD4

decimal

 +

 3


hexadecimal

C0

F3


 

After the third MOVE statement:

FIELD5

decimal

 0

 0

 0

 0

 0

 0

 0

 0

 2-

hexadecimal

F0

F0

F0

F0

F0

F0

F0

F0

D2


After the fourth MOVE statement:

FIELD2

decimal

 0

 0

 0

 0

 3

 +

hexadecimal

F0

F0

F0

F0

F3

4E


After the fifth MOVE statement:

FIELD3

decimal

 0

 0

 0

 0

 3

                    

hexadecimal

F0

F0

F0

F0

F3

40

40

40

40

40

40

40

40

40

40


After the sixth MOVE statement:

FIELD4

decimal

 0-

 2


hexadecimal

D0

F2