Hacker's Delight by Henry S. Warren

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Mon Sep 14 18:39:55 UTC 2009

This is a book for programmers who want to learn to write very efficient 
snippets of code.  It is in the spirit of (part of) hackmem, the famous 
MIT tech report.

I have not read "Hacker's Delight" nor bought it but it was
recommended to me by an even more ancient programmer.  We old
programmers grew up using assembly language and these old bit-fiddling
tricks still intrigue us.

There is a web page for the book and it lets you read chapter 1 for free.  

It introduces such tricks as:

	In C, how do you test if the integer x is a power of two?

	if ((x & x-1) == 0) ...

Note: this assumes that the arithmetic is done in two's complement.  I 
don't actually know any current C implementations that violate this, but 
it is possible for a conforming implementaion to use one's complement.

Many of these tricks are surprising.  As Guy Steele says in the
intro to the book, one can consume them like bonbons.
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists

More information about the Legacy mailing list