Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Arithmetic to bit string

  dcl A bit(1),
      D bit(5);
  A=1;         /* A has value '0'B     */
  D=1;         /* D has value '00010'B */
  D='1'B;      /* D has value '10000'B */
  if A=1 then go to Y;
         else go to X;

The branch is to X, because the assignment to A resulted in the following sequence of actions:

  1. The decimal constant, 1, has the attributes FIXED DECIMAL (1,0) and is assigned to temporary storage with the attributes FIXED BINARY(4,0) and the value 0001B.
  2. This value now converts to a bit string of length (4), so that it becomes '0001'B.
  3. The bit string is assigned to A. Since A has a declared length of 1, and the value to be assigned has acquired a length of 4, truncation occurs at the right, and A has a final value of '0'B.

For the comparison operation in the IF statement, '0'B and 1 convert to FIXED BINARY and compare arithmetically. They are unequal, giving a result of false for the relationship A=1.

In the first assignment to D, a sequence of actions similar to that described for A takes place, except that the value is extended at the right with a zero, because D has a declared length that is 1 greater than that of the assigned value.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)