Monday, 28 July 2014

COBOL Usage is Binary

In this case the data item is represented in pure binary. The it em must be an integer. Such data items are often used as subscripts. 

Depending on the size of the data item, it can be stored either in a 

  • Half-Word (2 bytes with range –32,768 to +32767).
  • Full-Word (4 bytes with range –2,147,483,648 to 2,147,483,647).

Format : 

Binary numbers are two, four, or eight bytes, depending on the number of digits that the Picture clause provides for. The leftmost bit of the number indicates whether the value is positive or negative.

Binary format (Binary, Comp, or Comp-4 usage) 

00 0B                Positive number with a value of +11
0C 41 2B 22       Positive number with a value of +205,597,474

The PICTURE Clause of a COMPUTATIONAL data item should not contain any character other than 9 or S.

When you use a data item mainly for arithmetic or as a subscript, code USAGE BINARY on the data description entry for the item. The operations for manipulating binary data are faster than those for manipulating decimal data.

Example : 

Created with Artisteer

No comments:

Post a comment