COBOL Sign Data type

COBOL Alphanumeric Data Type COBOL Assumed Decimal Point Data Type

Advertisements


Sign data type is all about to declare the sign value for the numeric data type.

Sign data type uses S to declare the data item with sign.

The SIGN clause is used for only a signed numeric data item or data item entry whose usage is DISPLAY, or a group data item containing at least one such similar data description entry.

It states the position of the sign, whether leading or trailing, as well as whether the sign was formed by over punching in the first or last character of the data item or was formed separately.

Sign data type declaration will come with a combination of numeric data type only.

The below table will represent SIGN Over punching.


Sign table

NumbersNumber +veNumber -veNumber No sign
0{}0
1AJ1
2BK2
3CL3
4DM4
5EN5
6FO6
7GP7
8HQ8
9IR9

Sign Example:


Below program shows the sign usage in COBOL program.


Code:



Output:



The below two additional options available in SIGN clause.


  1. Leading separate
  2. Trailing separate

Syntax:

[SIGN IS] {LEADING/TRAILING} [SEPARATE CHARACTER]

Parameters:

LEADING 	Indicates that the sign is at the beginning of the data 
                item. 
TRAILING        Indicates that the sign is at the end of the data item. 
SEPARATE        Indicates that the sign is not over punched on last/first 
                char of the data item and sign separately occupies the 
                first or last character of the data item

Note:
  1. SIGN S occupies extra 1 byte of storage space.
  2. If Nothing of the above parameters provided with SIGN clause, by default it is to SIGN IS TRAILING

Sign Leading/trailing Example:


Below program shows the sign leading/trailing coding in COBOL program.


Code:



Output:



COBOL Alphanumeric Data Type COBOL Assumed Decimal Point Data Type

Advertisements