Explain how XOR (^) bit operator works

Technology CommunityCategory: Bit ManipulationExplain how XOR (^) bit operator works
VietMX Staff asked 3 years ago

Bitwise XOR (exclusive or or exclusive disjunction) ( ^ ) like the other operators (except ~) takes two equal-length bit patterns. The XOR operator outputs a 1 whenever the inputs do not match.

XOR Truth Table
Input A	Input B	Output
0	      0	      0
0	      1	      1
1	      0	      1
1	      1	      0