Six bitwise operators & | ^ ~ <> & Bitwise AND operator: Calculate the location and binary length of a binary short value, that is, 1 & 1 = 1 & 0 = 0 0 & 0 = 0 | Press bitwise parallel operators perform parallel operations based on the position and length of the binary, that is, 1 | 1 = 1 1 | 0 = 1 0 | 0 = 0 ^ XOR operations are the same as 0, the difference is 1 1 ^ 1 = 0 0 ^ 0 = 0 1 ^ 0 = 1 ~ The inverse operation swaps 0 and 1 by 1110 ~ 0001 <left shift operation shifts the binary value to the left 110 <1 = 1100> right shift operation shifts the binary value to the right 110> 1 = 11 test code
# Include <bits/stdc ++. h> using namespace STD; int main () {int A, B; while (CIN> A> B) {cout <(A & B) <"\ n"; cout <(A | B) <"\ n"; cout <(a ^ B) <"\ n "; cout <(~ A) <"<(~ B) <"\ n"; cout <(A <2) <"\ n"; cout <(B> 2) <"\ n ";}}
Test Results
Bitwise operator Summary