Examples: numeric data and internal representation

The following table shows the internal representation of numeric items.

Table 1. Internal representation of numeric items
Numeric type PICTURE and USAGE and optional SIGN clause Value Internal representation
External decimal PIC S9999 DISPLAY + 1234    F1 F2 F3 C4
- 1234    F1 F2 F3 D4
  1234    F1 F2 F3 C4
PIC 9999 DISPLAY   1234    F1 F2 F3 F4
PIC 9999 NATIONAL   1234 00 31 00 32 00 33 00 34

PIC S9999 DISPLAY
  SIGN LEADING
+ 1234    C1 F2 F3 F4
- 1234    D1 F2 F3 F4

PIC S9999 DISPLAY
  SIGN LEADING SEPARATE
+ 1234 4E F1 F2 F3 F4
- 1234 60 F1 F2 F3 F4

PIC S9999 DISPLAY
  SIGN TRAILING SEPARATE
+ 1234 F1 F2 F3 F4 4E
- 1234 F1 F2 F3 F4 60

PIC S9999 NATIONAL
  SIGN LEADING SEPARATE
+ 1234 00 2B 00 31 00 32 00 33 00 34
- 1234 00 2D 00 31 00 32 00 33 00 34

PIC S9999 NATIONAL
  SIGN TRAILING SEPARATE
+ 1234 00 31 00 32 00 33 00 34 00 2B
- 1234 00 31 00 32 00 33 00 34 00 2D
Binary

PIC S9999 BINARY
PIC S9999 COMP
PIC S9999 COMP-4
+ 1234    04 D2
- 1234    FB 2E
PIC S9999 COMP-5 + 123451    30 39
- 123451    CF C7

PIC 9999  BINARY
PIC 9999  COMP
PIC 9999  COMP-4
  1234    04 D2
PIC 9999  COMP-5   600001    EA 60
Internal decimal

PIC S9999 PACKED-DECIMAL
PIC S9999 COMP-3
+ 1234    01 23 4C
- 1234    01 23 4D

PIC 9999  PACKED-DECIMAL
PIC 9999  COMP-3
  1234    01 23 4F
Internal floating point COMP-1 + 1234 43 4D 20 00
- 1234 C3 4D 20 00
COMP-2 + 1234 43 4D 20 00 00 00 00 00
- 1234 C3 4D 20 00 00 00 00 00
External floating point PIC +9(2).9(2)E+99 DISPLAY + 12.34E+02 4E F1 F2 4B F3 F4 C5 4E F0 F2
- 12.34E+02 60 F1 F2 4B F3 F4 C5 4E F0 F2
PIC +9(2).9(2)E+99 NATIONAL + 12.34E+02

00 2B 00 31 00 32 00 2E 00 33
00 34 00 45 00 2B 00 30 00 32
- 12.34E+02

00 2D 00 31 00 32 00 2E 00 33
00 34 00 45 00 2B 00 30 00 32
  1. The example demonstrates that COMP-5 data items can contain values of magnitude up to the capacity of the native binary representation (2, 4, or 8 bytes), rather than being limited to the value implied by the number of 9s in the PICTURE clause.