President Trump’s main opponent in November’s election will be determined by a vote at the Democratic convention this summer. That vote will be determined largely by the number of delegates each candidate for the Democratic nomination earns in the primaries and caucuses that began earlier this month. It’s possible that no candidate will earn enough delegates from those contests to clinch the nomination before the convention, meaning that the nominee may end up being determined either with the votes of freelance superdelegates or through horse trading of the committed delegates each campaign won. But that’s a discussion for a later day.

What’s important over the short term is to understand how those delegates committed to particular candidates — generally referred to as pledged delegates — are allocated. While this process is generally described as being a proportional allocation depending on the votes each candidate receives (more votes equals more delegates), it’s much more complicated than that. Because the allocation process might make it impossible for a candidate to clinch the nomination before the convention, allow us to explain how the delegate math actually works.

Most states will hold primaries in which delegates are allocated. In most of those contests, there are three pools of delegates awarded:

• Unpledged delegates, usually party officials, who will go to the convention with the ability to vote for whomever they wish.
• Pledged delegates awarded through the statewide vote.
• Pledged delegates awarded based on the results in individual congressional districts.

In other words, there are two tiers of contests: one at the state and one at the congressional level. There’s another complicating factor, too. Only candidates who receive at least 15 percent in voting receive any delegates at all.

So let’s walk through how this would work in a fictional scenario.

Imagine a state — let’s call it New Canada — in which there are 36 delegates at stake. Twenty are awarded based on the statewide vote and 16 based on the results in each of four congressional districts. There are five Democrats on the ballot: Adams, Barnes, Carter, Daines and Evers.

### Awarding the 20 statewide delegates

Adams received the most votes of the five candidates, earning 41.2 percent of the vote. Barnes was in second with 34.2 percent. Carter led the lower tier with 14.8 percent.

Carter, unfortunately, came just shy of the 15 percent threshold. Only Adams and Barnes passed it — meaning that only Adams and Barnes will get any of the statewide delegate total.

How are those delegates distributed? They’re awarded proportionally among those who hit the threshold. In essence, we throw out the votes received by Carter, Daines and Evers and recalculate the percentages earned by Adams and Barnes among the votes that remain.

In our example, Adams received 54.6 percent of those votes — 41.2 ÷ (41.2 + 34.2) — while Barnes got 45.4 percent. The other candidates got zero percent of those votes.

That, then, is how we distribute the delegates proportionally. Adams’s 54.6 percent is equivalent to 10.9 delegates (54.6 percent of the 20 delegates at stake). Barnes’s 45.4 percent is 9.1 delegates. We round, and Adams gets 11 delegates to Barnes’s nine.

You can already see how the overall proportionality breaks. Adams received 41 percent of the vote but 55 percent of the delegates. Carter got just under 15 percent of the vote — more than a third of Adams’s total — but zero delegates.

### Awarding the 16 congressional district delegates

That statewide total is a combination of the results in New Canada’s four congressional districts. Let’s say that the results in those districts looked like this.

How many delegates does each candidate get? Well, we first apply the 15 percent threshold again.

• In the 1st District, only Adams and Barnes surpassed 15 percent.
• In the 2nd, Adams, Barnes and Evers did.
• In the 3rd and 4th, Adams, Barnes and Carter did.

Now we recalculate the share of the vote in each district among those who hit the threshold.

And, once again, we convert those percentages into delegates.

Here, things get a little trickier.

In the 1st district, it’s straightforward. Both Adams and Barnes received two delegates after rounding. In the 2nd, similarly easy: two for Adams, one for Barnes and one for Evers.

In the 3rd, though, we have too many delegates awarded: both Adams’s and Barnes’s percentages round to two delegates, but Carter gets one as well. In the 4th District, we have too few, with Adams, Barnes and Carter each being awarded only one delegate apiece.

How to resolve this? Well, the rules vary in different states.

In the 3rd District case — too many delegates — the Democratic Party rules stipulate that delegates be awarded first by issuing a delegate for each whole number of delegates earned from the above calculation. In other words:

• Adams (1.74) gets one delegate.
• Barnes (1.56) gets one delegate.
• Carter (0.7) gets zero delegates.

Then, additional delegates are awarded in descending order of the remaining fractions. So:

• Adams (0.74) gets another delegate.
• Carter (0.7) gets one delegate.

And with that, the four delegates are allocated.

In the 4th District, we have a tie between Adams and Barnes. Who gets the fourth delegate? Well, let’s flip a coin! In this case, Barnes gets it — a happy coincidence given the delegate that wasn’t earned in the 3rd District.

Again, the rules in each state can vary slightly, though the 15 percent threshold is consistent. The best way to track the rules is to visit the Green Papers, a site dedicated to tallying and tracking the delegate allocations.

Back to New Canada, where we’re ready to start totaling our results. Combining state and district delegates gives us our final numbers:

• Adams: 18 delegates (11 statewide and seven in districts)
• Barnes: 15 (nine statewide and six in districts)
• Carter: 2 (both in districts)
• Daines: 0
• Evers: 1 (in the 2nd District)

In other words, Adams and Barnes end up winning a bigger chunk of the delegates than their statewide totals would suggest, simply because they hit the 15 percent threshold. Carter, who fell just short, isn’t shut out but gets fewer delegates than the almost-15 percent statewide total might suggest. Evers, by virtue of doing well in one district, ends up getting about the number of delegates that statewide percentages might indicate.

Perhaps the most important thing to take away from all of this is how close Adams and Barnes ended up. Adams “won” the state — that is, earned a plurality of the vote — but only got three more delegates than the runner-up. Hard to pull away in a system where runners-up still earn delegates.

On the first Tuesday of next month, about a third of the delegates at stake in the Democratic nominating contest will be awarded. Those delegates will be distributed using some version of the math above. But we can safely predict the outcome already: A handful of candidates will earn the bulk of the delegates, without a great distance between them.

The convention awaits.

###### clarification

Updated the math for the 3rd District example in accordance with the party rules.