BigETI

Swap issue

Dec 23rd, 2013
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.34 KB | None | 0 0
  1. // Example 1
  2. // Does not swap values (some of them inside the braces may return 0)
  3. my_array[i] ^= (my_array[i-1] ^= (my_array[i] ^= my_array[i-1]));
  4.  
  5. // Example 2
  6. // Works fine, just requires more lines, although it's the exact same technique as above
  7. my_array[i] ^= my_array[i-1];
  8. my_array[i-1] ^= my_array[i];
  9. my_array[i] ^= my_array[i-1];
Advertisement
Add Comment
Please, Sign In to add comment