Count One Bits
Count 1-bits (Hamming weight) in binary/hex/decimal numbers. Width selector, batch, TSV export. Free, client-side.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Count the number of 1-bits (Hamming weight / popcount) in numbers across binary, hex, or decimal input - auto-detected by default. Per-row breakdown shows binary representation, 1s/0s counts, percentage, and which positions hold the 1-bits.
Summary
Per-row breakdown
How to Use Count One Bits
- Paste numbers, one per line. Auto-detect figures out format per line (binary if all 0s and 1s, hex if hex letters or has
0xprefix, otherwise decimal). - Pick bit width: Natural uses each input's own bit count; fixed widths (8/16/32/64) pad with leading zeros for consistent comparison.
- The table shows binary representation, 1s count, 0s count, total bits, percentage, and the bit positions of 1s (LSB = position 0).
- Download as TSV for spreadsheet analysis.
Frequently Asked Questions
What’s a Hamming weight / popcount?
The Hamming weight of a binary number is the number of 1-bits it contains. Also called population count (popcount) – it’s a primitive operation in many CPUs (the POPCNT instruction). Used in cryptography, error correction, bitset operations, and combinatorial math.
How does auto-detect decide format?
Priority order: 0b... prefix → binary; 0x... prefix → hex; all 0/1 digits → binary; contains a-f → hex; all 0-9 → decimal. Ambiguous strings (e.g., 10 – binary 2 or decimal 10?) get treated as binary. Use explicit format selector or 0x/0b prefixes to disambiguate.
Why does bit width matter?
Natural width counts only the bits actually present (e.g., 0b1010 = 4 bits). Fixed widths pad with leading zeros: 0b1010 at 8-bit = 00001010, still 2 ones but now 6 zeros. The 1s count never changes – only the 0s count and percentage do.
What are bit positions?
Indices where 1-bits sit, counted from the LSB (least significant bit) = position 0. 0b1010 has 1s at positions 1 and 3. Useful for bitmasks, set-theoretic operations, finding which flags are set.
What’s the maximum input value?
JavaScript’s BigInt handles arbitrary precision, so practically unlimited – limited only by browser memory. A 1000-character binary string parses fine.
How does it handle leading zeros?
Binary input 0001010 has natural width 7 (the leading zeros count toward total bits). Hex 0F has natural width 8 (2 hex chars × 4). Decimal natural width is the minimum bits needed.
What about negative numbers?
Not directly supported as -N. For two’s-complement bit patterns, convert to the appropriate hex or binary form first (e.g., -1 as 8-bit signed = 0xFF).
Why might a line fail?
Lines that don’t match any format (e.g., FFG, five, 3.14) error individually without stopping the batch. The error count appears in stats, and individual error positions show in the status line.
Is anything uploaded?
No. Everything runs in your browser with JavaScript – nothing is sent to a server, logged, or stored, and the tool keeps working offline once the page has loaded.
What’s the row cap?
500 rendered in the table to keep the page responsive. The TSV download includes all rows.
Related Tools
Count Zero Bits →
Count 0 bits in binary strings. Free, secure, instant, 100% client-side processing.
Rotate Binary Bits →
Rotate the bits of each binary value to the left, wrapping bits around. Free,…
Shuffle Binary Bits →
Randomly shuffle the order of the bits in each binary value. Free, private, and…
Count List Items →
Count list items with frequency analysis, duplicates, unique-only output, TSV export. Free, client-side, instant.
Count Unicode Characters →
Count Unicode Characters online, free and private. Runs in your browser, no upload, instant…
Create Image With One Color →
Create solid color images at any size with optional alpha transparency. 8 quick presets.…
Flip ASCII Bits →
Flip every bit of each character in your text and see the result as…
Shuffle ASCII Bits →
Randomly shuffle the bits of each character in your text for a scrambled result.…
Calculate Bitwise AND of Binary Values →
Calculate Binary Values Online Free - Fast and accurate binary computations for developers, students,…
Binary to Decimal Converter →
Convert extremely large machine binary strings natively into format decimal bounds infinitely fast offline…
Calculate Binary Addition →
Calculate Binary Addition numbers with carry visualization and multi-format output. Free, offline, client-side, instant…
BCD to Decimal Converter →
Convert packed BCD to decimal - binary or hex input, COMP-3 signed nibbles, batch…