News for hackers. Stuff that matters.
Re:20 bit operations programmers should know by frontfor on Saturday June 08, 2013 @08:35AM (#5844716)
While the techniques described here are academically interesting, don't expect your code to run magically faster if you use them in practice. I once benchmarked the performance of the "common version" of #9 implemented in C compared to swapping using a temporary variable like so:

int tmp = a; a = b; b = tmp;

It turned out that the bitwise swap was slower. In other words this sort of "clever" bit-level hack does not necessarily translate to higher performance.

And I would recommend the first chapter of "Matters Computational" written by Jörg Arndt, which includes many more advanced bitwise operations: http://www.jjj.de/fxt/#fxtbook. This book is more like a cookbook rather than an introductory book.

EDIT: debugged!

Re:20 bit operations programmers should know by Jabbles on Saturday June 08, 2013 @08:36AM (#5844719)
I think you have a bug in your swap routine :P
Re:20 bit operations programmers should know by frontfor on Saturday June 08, 2013 @08:40AM (#5844729)
That's embarrassing. I think I'm sleep deprived.