Calculators
Bit Count Calculator
Count set bits (population count), bit length and binary zeros of an exact nonnegative integer in your browser.
Count the 1 bits in the binary representation of a nonnegative decimal integer. For 255, binary 11111111 has 8 set bits. Zero has bit length 0. Enter up to 1000 digits; calculations stay in your browser.
How population count works
The population count, also called Hamming weight, is the number of 1 bits in an integer’s binary representation. For 13, binary 1101 has three set bits and a bit length of four, leaving one zero within that length. For 255, binary 11111111 has eight set bits. Bit length excludes leading zeros: a positive integer needs floor(log2(n)) + 1 bits. Zero is displayed as binary 0 but has bit length zero and no set bits or counted zero bits. Parity reports whether the set-bit count is even or odd; it is not the parity of the original integer. This tool uses the minimal unsigned representation rather than a fixed-width machine word and does not accept negative or two’s complement inputs. Enter 1 to 1000 decimal digits without signs, separators, decimals or exponent notation. Surrounding whitespace is accepted and leading decimal zeros are removed. Exact BigInt arithmetic preserves all digits. All calculations stay in your browser.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
What is a set bit?
A set bit is a binary digit equal to 1. The integer 13 is binary 1101, so its population count is 3.
How is zero handled?
Zero has no set bits and a bit length of zero. Its displayed binary representation is 0, but that display digit is not counted as a storage bit.
Does this use 32-bit or 64-bit integers?
No. It uses the minimal unsigned binary representation with exact BigInt arithmetic. Leading zeros and fixed-width padding are not included.
Can I enter hexadecimal or negative values?
No. Enter 1 to 1000 nonnegative decimal digits. Signs, decimal points, separators and prefixes such as 0x are rejected.
Is bit-count parity the same as odd or even numbers?
No. It describes the number of set bits. For example, 3 is odd but binary 11 contains an even count of two set bits.