Daily Archives: 9/8/2009

HAKMEM 175

HAKMEM is a legendary technical memo from MIT that’s packed full of interesting bits. On this occasion, I ran across item #175, which you can find here:

HAKMEM 175

This is a little chunk of code which given an integer, computes the next highest integer with the same number of one bits. This code is expressed somewhat sub-optimally for modern audiences, since it is PDP-10 assembly code, but encompasses a neat, but subtle algorithm. One might ask what use such a seemingly esoteric function is, but it is quite useful in quickly generating all subsets with a given number of elements. Nifty.