SyntaxFix
Write A Post
Hire A Developer
Questions
If you happen to be using Java, the built-in method Integer.bitCount will do that.
Integer.bitCount