Source: wikibot/xor-swap-algorithm
= XOR swap algorithm
{wiki=XOR_swap_algorithm}
The XOR swap algorithm is a method for swapping the values of two variables using the bitwise XOR operator. The key idea is to use XOR to manipulate the bits of the two variables without needing a temporary variable. Here's how it works step by step: Suppose we have two variables, \`a\` and \`b\`. 1. **Step 1:** Perform the XOR operation on \`a\` and \`b\`, and store the result back in \`a\`.