Count number of set bits in an integer
1 2 count = 0 3 count += byte & 1 and byte >>= 1 until byte == 0
DZone Snippets > peter > count
12738 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Peter Cooperx http://www.petercooper.co.uk/
1 2 count = 0 3 count += byte & 1 and byte >>= 1 until byte == 0