Java Term of the Week: Bitwise Operator
Bitwise operators perform operations on the bits of their operands. The operands can only be byte, short, int, long or char data types. For example, if an operand is the number 48, the bitwise operator will perform its operation on the binary representation of 48 (i.e., 110000).
There are three binary logical operators:
& performs a logical AND operation. ^ performs a logical OR operation. | performs a logical XOR operation.
There are three bit shift operators:
>> the signed left shift operator shifts the bits of a binary number to the left. << the signed right shift operator shifts the bits of a binary number to the right. >>> the unsigned right shift operator shifts the bits of a binary number to the right, filling the left most bit with a zero.
And finally the unary operator:
~ the bitwise complement operator inverts the bits of a binary number.


No comments yet. Leave a Comment