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
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.