How Signed Numbers are Stored


Micro Focus Personal COBOL for Windows

The sign in a signed numeric field does not have to take up a separate byte of storage. The example below shows how a four digit signed numeric value is actually stored using an embedded sign.

        PIC S9(4)

              Stored      Actual
               Value       Value

                001u       -15
                001t       -14
                001s       -13
                001r       -12
                001q       -11
                001p       -10
                000y        -9
                000x        -8
                000w        -7
                000v        -6
                000u        -5
                000t        -4
                000s        -3
                000r        -2
                000q        -1
                0000         0
                0001        +1
                0002        +2
                0003        +3
                0004        +4
                0005        +5
                0006        +6
                0007        +7
                0008        +8
                0009        +9
                0010       +10
                0011       +11
                0012       +12
                0013       +13
                0014       +14
                0015       +15

Embedded signs are discussed in the text on pp. 406-408 and Fig. 14.3 on p. 407.


Cobol Home