# Perform bitwise binary operations

The bitwise binary operations AND, OR and XOR performs calculations on two bit strings of the same length. The result is a new bit string were the value of each bit only depends on the bits at the same position in the original bit strings.

With the help of this tool you can easily compare and see for yourself how the different operations work. The tool can handle up to 31 bits. Leading bits that are zero in both operands are ignored because they don't affect the result. All three operations result in zero for a certain position if the bits at that position in the two operands are zero.

## AND

The result of the bitwise AND operation is 1 at those positions that are 1 in both operands. Bitwise AND can be seen as pairwise multiplication between the bits of the two operands. For the product to be 1 it is necessary that both bits are 1. Most programming languages (C++, Java, Python, etc.) uses the symbol & to perform bitwise AND operations.

 1100 AND 1010 1000

## OR

The result of the bitwise OR operation is 1 at those positions that are 1 in at least one of the operands. To perform bitwise OR most programming languages uses the symbol |.

 1100 OR 1010 1110

## XOR

The result of the bitwise XOR operation is 1 at the positions where the bits have different values in the two operands. Most programming languages uses the symbol ^ to perform the bitwise XOR operation.

 1100 XOR 1010 0110