Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bitwise operation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===XOR=== [[File:Z2^4; Cayley table; binary.svg|thumb|Bitwise XOR of 4-bit integers]] A '''bitwise XOR''' is a [[binary operation]] that takes two bit patterns of equal length and performs the [[Exclusive disjunction|logical exclusive OR]] operation on each pair of corresponding bits. The result in each position is 1 if only one of the bits is 1, but will be 0 if both are 0 or both are 1. In this we perform the comparison of two bits, being 1 if the two bits are different, and 0 if they are the same. For example: 0'''10'''1 (decimal 5) XOR 0'''01'''1 (decimal 3) = 0'''11'''0 (decimal 6) The bitwise XOR may be used to invert selected bits in a register (also called toggle or flip). Any bit may be toggled by XORing it with 1. For example, given the bit pattern 0010 (decimal 2) the second and fourth bits may be toggled by a bitwise XOR with a bit pattern containing 1 in the second and fourth positions: '''0'''0'''1'''0 (decimal 2) XOR '''1'''0'''1'''0 (decimal 10) = '''1'''0'''0'''0 (decimal 8) This technique may be used to manipulate bit patterns representing sets of Boolean states. [[Assembly language]] programmers and optimizing [[compiler]]s sometimes use XOR as a short-cut to setting the value of a register to zero. Performing XOR on a value against itself always yields zero, and on many architectures this operation requires fewer clock cycles and less memory than loading a zero value and saving it to the register. If the set of bit strings of fixed length ''n'' (i.e. [[Word (computer architecture)|machine words]]) is thought of as an ''n''-dimensional [[vector space]] <math>{\bf F}_2^n</math> over the [[Field (mathematics)|field]] [[GF(2)|<math>{\bf F}_2</math>]], then vector addition corresponds to the bitwise XOR.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)