BINDEC(digits {: decimal-positions})

The BINDEC keyword is a numeric data type keyword. It is used in a free-form definition to indicate that the item has binary-decimal format.

It must be the first keyword.

The first parameter is required. It specifies the total number of digits. It can be a value between 1 and 9.

The second parameter is optional. It specifies the number of decimal positions. It can be a value between zero and the number of digits. It defaults to zero.

Each parameter can be a literal or a named constant. If it is a named constant, the constant must be defined prior to the definition statement.

In the following example
  • field salary is defined as a binary-decimal field with 5 digits and 2 decimal places
  • field age is defined as a binary-decimal field with 3 digits and the default of 0 decimal places
  • field price is defined as a binary-decimal field with 7 digits and 3 decimal positions. The number of decimal positions is defined using named constant NUM_DEC_POS.

  DCL-S salary BINDEC(5 : 2);
  DCL-S age BINDEC(3);
  DCL-C NUM_DEC_POS 3;
  DCL-S price BINDEC(7 : NUM_DEC_POS);