*BitAnd Operator

Used to perform a logical conjunction on two Boolean expressions, or a bitwise conjunction on two integer values.

    
        result
          =expression1*BitAndexpression2

Parts

result

Required. Any Boolean or numeric expression. For Boolean comparisons, the result is the logical conjunction of two expressions. For bitwise operations, the result is a numeric value resulting from the bitwise conjunction of two numeric expressions.  

expression1

Required. Any Boolean or numeric expression.

expression2    

Required. Any Boolean or numeric expression.  

Remarks

For Boolean comparison, if both expression1 or expression2 evaluate to True, result is True. If expression1 evaluates to True, and expression2 evaluates to False the result is False. If expression1 evaluates to False, and expression2 evaluates to True, the result is False. The following table illustrates how result is determined:

 

If expression1 is And  expression2 is Then result is
True True True
True False False
False True False
False False False

 

For bitwise operations, the *bitAnd operator performs a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

 

If bit in expression1 is And bit in expression2 is Then result is
0 0 0
0 1 0
1 0 0
1 1 1

 

Note    Since the logical/bitwise operators have a lower precedence than other arithmetic and relational operators, any bitwise operations should be enclosed in parentheses to ensure accurate execution.

If the operands consist of one Boolean expression and one numeric expression, the result Boolean expression will be converted to a numeric value (-1 For True, and 0 For False) and the bitwise operation will result.

Example

dclconst   Hex24  Value( H'24' )
dclfld     Byte1  Type( *byte ) INZ( H'46')
dclfld     Byte2  Type( *byte )
dclfld     Int1   Type( *integer2 ) INZ( H'46' )
dclfld     Int2   Type( *integer2 )
dclfld     Bool1  Type( *Boolean ) INZ( *true )
dclfld     Bool2  Type( *Boolean )
dclfld     Str2   Type( *string )

Byte2 = Byte1 *BitAnd Hex24          // Byte2 = H'04'
Int2  = Int1  *BitAnd Hex24          // Int2 = 4 or H'0004'
Bool2 = Int2  *BitAnd H'11'          // Bool2 = False
Str2  = Int1  *BitAnd Hex24          // Str2 = "4"
Int2  = Bool1 *BitAnd H'0C00'        // Int2 = 4 or H'0004"

See Also