Java Reference
In-Depth Information
Table A.2.6
Bitwise operators. x and y are integers. If mixed integer types, the
result will be of the wider type.
Operator
Name
Description
Flip each bit, ones to zeros, zeros to ones.
~x
Compliment
AND each bit a with corresponding bit in b.
x&y
AND
x | y
OR each bit in a with corresponding bit in b.
OR
x ^ y
XOR each bit in x with corresponding bit in y.
XOR
x << y
Shift x to the left by y bits. High-order bits
lost.
Zero bits fill in right bits.
Shift left
Shift x to the right by y bits. Low-order bits
lost.
Same bit value as sign (0 for positive
numbers, 1 for negative) fills in the left
bits.
x >> y
Shift right
-
Signed
Shift x to the right by y bits. Low-order bits
lost.
Zeros fill in left bits regardless of sign.
x >>> y
Shift right
-
Unsigned
Search WWH ::




Custom Search