Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

XOR swap algorithm

Numerical Algorithm

The XOR swap algorithm, also called the exclusive or swap, uses the exclusive-or bitwise operation to exchange the values of two variables without using the temporary variable that a conventional swap normally requires. It relies purely on bitwise arithmetic between the two variables themselves rather than on an external storage location. This description is adapted from Wikipedia contributors under CC BY-SA 4.0; changes were made. https://creativecommons.org/licenses/by-sa/4.0/

Sources
Wikipedia: XOR swap algorithm
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.