An article I wrote a few years ago and thought nobody cared about. Apparently it seems to have been linked a lot so I'm putting it back:
The article was translated into Russian (not by me, but thanks to the person who did it and linked back to my website): http://blog.topgun.kiev.ua/?p=2501
Disclaimer: the trick is not widely known but it's not mine, I have seen it around in several pieces of code. I only attempted to explain it.