XOR Swap Algorithm

XOR Swap Algorithm

In computer programming, the XOR swap is an algorithm that uses the XOR bitwise operation to swap values of distinct variables having the same data type without using a temporary variable. "Distinct" means that the variables are stored at different memory addresses; the actual values of the variables do not have to be different.

Read more about XOR Swap Algorithm:  The Algorithm, Proof of Correctness, Code Example, Reasons For Use in Practice, Reasons For Avoidance in Practice, Variations

Famous quotes containing the word swap:

    If we should swap a good library for a second-rate stump speech and not ask for boot, it would be thoroughly in tune with our hearts. For deep within each of us lies politics. It is our football, baseball, and tennis rolled into one. We enjoy it; we will hitch up and drive for miles in order to hear and applaud the vitriolic phrases of a candidate we have already reckoned we’ll vote against.
    —Federal Writers’ Project Of The Wor, U.S. public relief program (1935-1943)