in reply to counting set bits in binary file

A somewhat related subject had been discussed throughly at clpmisc in this thread: count of 1s in a binary number (this is a Google groups link). IMHO it is worth reading in any case. Of course you have the added problem of reading in from a file, but in that case I guess that you may read in chunks and sum up...