How to Swap Two Variables Using XOR @WhatsACreel
How to Swap Two Variables Using XOR  @WhatsACreel
Uploaded June 2014 | Updated November 2026, 1 day ago
In this video we'll explore one of the most simple, clever and despised of all bit hacks, the famous XOR swap!

The objective is to swap the values in two variables. In this video we'll explore four methods for achieving this, one of which is the XOR swap itself. We'll also look at the most common method, which uses a temporary variable. We'll look at the XCHG instruction and another very interesting swap called the Arithmetic Swap.

If my explanation of why the XOR swap works does not make sense to you, don't worry, it doesn't make sense to me either. XOR swap is one of those peculiar little gems of logic that I find only makes sense for a brief instant every now and again. Then I forget how it works again, and am left to marvel at its novelty with the happy bliss of ignorance.
How to Swap Two Variables Using XORASM Optimization: Fast Multiplicationx64 Assembly MultiThreading 1: Intro and Calling CreateThreadNeural Net Structure (Architecture)AES Encryption 2: AddRoundKey, SubBytes and ShiftRowsx64 Assembly Self Modifying CodeLinux x64 Assembly Tutorial 7: Jump and Branch InstructionsNVIDIA CUDA Tutorial 3: Display Driver has Stopped Working and has RecoveredAssembly Language MisconceptionsC++ Function Templatesx64 Assembly Tutorial 47: Intro to SSEC++ 11: Range Based For Loops
Creel |

How to Swap Two Variables Using XOR

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER