Defining numeric data
Define numeric items by using the
with the character
9 in the data description to represent
the decimal digits of the number. Do not use an
which is for alphanumeric data items.
is a numeric data item, an external decimal item that has
DISPLAY (a zoned decimal item):
05 Count-y Pic 9(4) Value 25.
05 Customer-name Pic X(20) Value "Johnson".
You can similarly define numeric data items to hold national
characters (UTF-16). For example,
Count-n below is
an external decimal data item that has
USAGE NATIONAL (a national
05 Count-n Pic 9(4) Value 25 Usage National.
You can code
up to 18 digits in the
PICTURE clause when you compile
using the default compiler option
to as compatibility mode). When you compile using
to as extended mode), you can code up to 31 digits in
Other characters of special significance that you can code are:
- Indicates leading or trailing zeros
- Indicates a sign, positive or negative
- Implies a decimal point
s in the following example
means that the value is signed:
05 Price Pic s99v99.
The field can therefore hold a positive or a negative
v indicates the position of an implied
decimal point, but does not contribute to the size of the item because
it does not require a storage position. An
does not contribute to the size of a numeric item, because by default
not require a storage position.
However, if you plan to port your program or data to a different machine, you might want to code the sign for a zoned decimal data item as a separate position in storage. In the following case, the sign takes 1 byte:
05 Price Pic s99V99 Sign Is Leading, Separate.
This coding ensures that the convention your machine uses for storing a nonseparate sign will not cause unexpected results on a machine that uses a different convention.
Separate signs are also preferable for zoned decimal data items that will be printed or displayed.
Separate signs are required for national decimal data items that are signed. The sign takes 2 bytes of storage, as in the following example:
05 Price Pic s99V99 Usage National Sign Is Leading, Separate.
cannot use the
PICTURE clause with internal floating-point
you can use the
VALUE clause to provide an initial
value for an internal floating-point literal:
05 Compute-result Usage Comp-2 Value 06.23E-24.
For information about external floating-point data, see the examples referenced below and the related concept about formats for numeric data.
Displaying numeric data
Controlling how numeric data is stored
Defining national numeric data items
Sign representation of zoned and packed-decimal data
Storage of character data
SIGN clause (Enterprise COBOL for z/OS® Language Reference)