in reply to counting set bits in binary file

See Loops loosing Performance for a recent discussion about this, and this reply in particular. Synopsis: use a 256- or 65536-entry lookup table.

Hugo