Boolean Operators
Boolean operators are 1 bit in PLI language. You can use for conditional logic very often in PLI language.
In PL/I
Bit(1) strings represents single Boolean values
'1'B
is interpreted asTrue
'0'B
is interpreted asFalse
Bit(1) strings may be used as boolean expressions in conditional and loop statements.
declare my_bit bit (1); my_bit = ( 1 < 2 ); /* now my_bit has the value '1'B */ my_bit = ( 2 < 1 ); /* now my_bit has the value '0'B */ ..... if my_bit then put skip list ( 'value of my_bit is true' ); else put skip list ( 'value of my_bit is false' ); do while ( my_bit ); ..... end;
Boolean operators may be used for calculating new values
- The prefix operator
¬
is used as logicalNOT
. - The infix operator
&
is used as logicalAND
. - The infix operator
|
is used as logicalOR
.
How to declare Boolean values
declare bit_a bit (1); declare bit_b bit (1); declare result bit (1); result = ¬ bit_a; /* result = '1'B if and only if bit_a is '0'B */ result = bit_a & bit_b; /* result = '1'B if and only if both bit_a and bit_b are '1'B */ result = bit_a | bit_b; /* result = '0'B if and only if both bit_a and bit_b are '0'B */
Note: Using compile-time options NOT
operator and OR
operator may be replaced by other symbols, for being compatible with existing PL/I programs often ^
is used as NOT
, !
is used as OR
.