How it works
Cryptographic Random vs Math.floor: Fairness
Every online flip claims to be random. Very few say what that word means, which is the entire problem. The browser hands JavaScript two very different tools with the same-looking name, and the choice between them decides whether your heads/tails is a fair, tamper-proof 50/50 or an educated guess in a party hat. This is the difference, in plain words.
The one most sites use is Math.random(). It is fast, cheap and built for games and shuffles, not for bets on fairness. It is a pseudorandom generator: a careful-looking sequence with an arithmetic engine underneath that, in principle, can be predicted if you watch enough output. Nothing is malicious about it — it simply was never designed to resist being figured out.
The alternative: entropy straight from the OS
The cryptographic route, exposed as crypto.getRandomValues(), skips the predictable engine and pulls randomness from the operating system's entropy pool — the same noisy, hard-to-guess source used to secure connections, tokens and cash registers. It uses real physical and system noise, not arithmetic, so its output carries the property security researchers actually mean by "random": nobody, including any observer of past flips, can predict the next one.
The difference shows in what each generator promises. Math.random() promises speed; crypto.getRandomValues() promises unpredictability. For a game animation you barely notice the luxury. For a coin that is supposed to be beyond suspicion, unpredictability is not a bonus — it is the product.
Where floating-point bias sneaks in
A fair flip also depends on how you carve a random value into a side. The careless recipe — Math.floor(Math.random() * 2) — takes a number so uniform it spans a huge range and smashes it down to two buckets. Done naively, rounding boundaries can give one bucket a whisper more than the other. A well-made flip avoids conversion entirely: it takes a raw integer of even size, which splits into heads and tails with mathematically zero bias. That is the craft detail that turns "appears random" into "demonstrably even."
That is why the tailsnow flip calls a cryptographic source and divides a whole, even-width integer rather than rounding a floating decimal. Same click, same spin — but the odds are no longer a matter of trust. They are a matter of construction.