04 Try it yourself Interactive

From a margin to a total

Give the winner’s percentage of the valid votes, the majority in votes, and what share of the votes cast were invalid. The console derives the loser’s share, the gap, the valid votes and — when there are invalid votes — the total cast, keeping the two bases explicitly separate.

Winner 57%, majority 42,000, none invalid
gap 14% · total 3,00,000
Set the invalid share to 0% for the simple two-candidate case. Above zero, watch the last step change base from valid votes to votes cast.
Press Next to work through it one step at a time.
Winner
Gap %
Valid votes
Total cast
step 0 / 0