GitHub - emilbayes/popcnt32: Calculate population count (popcnt) on a 32-bit number, branch free
Skip to content

Calculate population count (popcnt) on a 32-bit number, branch free

License

Notifications You must be signed in to change notification settings

emilbayes/popcnt32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

popcnt32

Calculate population count (popcnt) on a 32-bit number, branch free

Usage

var popcnt32 = require('popcnt32')

popcnt32(0b1) // 1
popcnt32(0b1000001) // 2

API

const ones = popcnt32(int)

Return number of 1-bits in int. Int is implicitly cast to a 32-bit unsigned int. This means popcnt32(-1) === 32 while popcnt32(1) === 1

Install

npm install popcnt32

License

ISC

About

Calculate population count (popcnt) on a 32-bit number, branch free

Resources

License

Stars

Watchers

Forks

Packages

No packages published