RPGLANGUAGE . COM

%BITAND, %BITOR, %BITXOR, %BITNOT

This table describes the bit functions supplied in free-form RPG.

BITAND BITOR BITXOR BITNOT

If the bits in the same position in all the input parameters are 1, BITAND will return 1 in that position.
Otherwise, it will return 0.

If any bit is 1 in at least one input parameter, BITOR will return 1 in that position.
Otherwise, it will return 0.

If any bit is 1 in only one input parameter, BITXOR will return 1 in that position.
Otherwise, it will return 0.

Each 1 in the input parameter is returned as 0 and each 0 is returned as 1.

Input 1 1001 0110
Input 2 1111 0000
Returns 1001 0000
Input 1 1001 0110
Input 2 1111 0000
Returns 1111 0110
Input 1 1001 0110
Input 2 1111 0000
Returns 0110 0110
Input1001 0110
Returns 0110 1001

BITAND takes two or more input parameters and returns a value. The parameters and return value are either character or numeric (integer or signed numeric).

BITOR takes two or more input parameters and returns a value. The parameters and return value are either character or numeric (integer or signed numeric).

BITXOR takes two input parameters and returns a value. The parameters and return value are either character or numeric (integer or signed numeric).

BITNOT takes one input parameter and returns a value. The parameter and return value are either character or numeric (integer or signed numeric).