Bitwise Operators

Top  Previous  Next

Operators:  &  ^  |

Syntax:

expression1 & expression2

bitwise AND

expression1 ^ expression2

bitwise XOR

expression1 | expression2

bitwise OR

 

The bitwise operators convert both expressions to Number, if necessary, and then both are converted to internal integer format. Each operator compares each bit of expression1 with the corresponding bit of expression2 and produces a result bit according to the following table:

 

expr1

expr2

AND

XOR

OR

0

0

0

0

0

0

1

0

1

1

1

0

0

1

1

1

1

1

0

1

 

The operator is applied to each of the 32 bits of the expressions for a 32-bit result.