Count One Bits screenshot

Count One Bits

Count the 1 bits in each pasted binary value and the total across the list.

Privacy First
0 Runs
Updated 2026-11-06
No upload

What this page computes

Paste binary values one per line and the page counts the positions holding a 1 in each value, then sums those counts. This is the Hamming weight of each line, printed beside the line it belongs to.

Where it stops

The count is taken over the printed width, so 0011 reports two ones rather than two out of two bits of a value. Anything other than 0 or 1 on a line is refused by line number, and an empty box is refused rather than answered with zero.

Why the answer repeats

Counting is a loop over the pasted characters: no fetch, no storage, no clock. The same paste prints the same figures on every reload, and the text never leaves the browser.

Per-line popcount of pasted binary values plus their total, counted over the printed width rather than the numeric value. Leading zeros count as zeros; a line holding anything but 0 and 1 is refused by line number.

How to use it

Paste binary values one per line and press Run. Each line reports its own count and the last line sums them.

The arithmetic

Leading zeros are significant because the input is a bit string: 0011 has two ones, which a count on the value 3 would present as two out of two bits.

What to Expect

Best for

  • teaching Hamming weight
  • checking the popcount of a mask

What this tool keeps

  • the per-line count and the total

Sample input

1011 / 0011 (one per line)

Sample output

1011 has 3 one bit(s) 0011 has 2 one bit(s) Total = 5 one bits across 2 value(s)

Frequently asked questions

How do I use the count one bits page?

Paste binary values one per line, then press Run. Each line gets its own count and the last line is the sum.

Is anything uploaded?

No. The whole calculation runs in this tab with JavaScript: no request is made, no account is needed, nothing is stored, and the page keeps working offline once it has loaded.

What are its limits or bounds?

Every line must contain only 0 and 1 and the box must not be empty. Leading zeros are counted as zeros, because the input is a bit string rather than a number.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.