Fun

Coin flipper

Flip a coin as many times as you like and watch the heads and tails counts build up, with the share of each side shown as it goes.

Runs locally in your browser

How it works

Each flip asks the browser for one 32-bit random number and takes it modulo 2: an even number is heads, an odd number is tails. A 32-bit number has 2^32 possible values, and 2^32 is even, so the two outcomes split the range exactly in half, with 2^31 values each. Nothing is discarded and neither side is favoured. The helper this page uses also contains a guard that would redraw values for a range that does not divide 2^32 evenly, but with two outcomes that guard can never fire. Every flip is independent of the ones before it. The counters live in this page only: they start at zero and go back to zero when you press reset or reload. Each percentage is that count divided by the total flips so far.

Worked example

If the first four flips came out heads, tails, heads, heads, the counter would read heads 3, which is 3 ÷ 4 × 100 = 75.0%, tails 1, which is 25.0%, and a total of 4. Each flip is independent, so that 75% is just what happened in those four flips, not a prediction for the next one.

Questions and answers

Everything runs in your browser: your text, file or value is never uploaded anywhere.