Post #1
0 votes
Sam
Reputation
5
Posts: 28
Joined: Jul 1, 2026, 2:30 PM
Posted: Jul 29, 2026, 9:30 AM
Tutorial says PIC 9 is numeric and PIC X is alphanumeric. Can I store numbers in PIC X? What breaks if I do math on a PIC X field?
Tutorial says PIC 9 is numeric and PIC X is alphanumeric. Can I store numbers in PIC X? What breaks if I do math on a PIC X field?
You can put digits in PIC X but it is still text. ADD / COMPUTE want numeric (PIC 9). Doing arithmetic on PIC X is asking for trouble.
Rule of thumb: counting and money = PIC 9 (often COMP-3). Names, codes, flags = PIC X.
Also watch leading zeros. PIC 9(5) holding 42 is 00042 in storage. PIC X(5) with 42 is usually "42" left-justified with spaces.
You must be signed in to reply to this thread