src/util.js
// Number of set bits in a U32. See "Hacker's Delight" chapter 5
Number of set bits in a U32. See "Hacker's Delight" chapter 5
Number of set bits in a U32 . See " Hacker ' s Delight " chapter 5
function population(x) {
  x = (x & 0x55555555) + (x >>> 1  & 0x55555555)
  x = (x & 0x33333333) + (x >>> 2  & 0x33333333)
  x = (x & 0x0F0F0F0F) + (x >>> 4  & 0x0F0F0F0F)
  x = (x & 0x00FF00FF) + (x >>> 8  & 0x00FF00FF)
  x = (x & 0x0000FFFF) + (x >>> 16 & 0x0000FFFF)
  return x | 0
}
function population ( x ) { x = ( x & 0x55555555 ) + ( x >>> 1 & 0x55555555 ) x = ( x & 0x33333333 ) + ( x >>> 2 & 0x33333333 ) x = ( x & 0x0F0F0F0F ) + ( x >>> 4 & 0x0F0F0F0F ) x = ( x & 0x00FF00FF ) + ( x >>> 8 & 0x00FF00FF ) x = ( x & 0x0000FFFF ) + ( x >>> 16 & 0x0000FFFF ) return x | 0 }
Number of set bits in a U32.
Number of set bits in a U32 .