YoYo Games Wiki

Talk:XOR Swap Algorithm

From YoYoGames Wiki

This algorithm is useful but not in Game Maker

The variables in GM store floating point values. So this method cannot swap values like 2.2 and 3.7. Also it make no speed benefits before

  var a, b;
  a = some_value;
  b = some_value;
  // Swap 'a' and 'b'
  var t;
  t = a;
  a = b;
  b = a;

So think twice before using it. --Tolich 10:50, 23 September 2008 (UTC) Moreover, if one of variable is actually a string, the code will crash. Tolich 07:44, 14 October 2008 (UTC)