Northern Ireland uses the Single Transferable Vote (STV) system to elect members of the Northern Ireland Assembly, local councils and members of the European Parliament.
Here's how the system works, with an example of how the outcome was calculated last time round.
Under STV, candidates are elected according to the share of vote they receive, the size of the electorate, and the number of seats to be filled.
Voters rank candidates in order of preference, giving each a number. They can choose as many or as few as they like.
Next, the 'quota' has to be worked out, which establishes the minimum number of votes a candidate requires to be elected.
In Northern Ireland, a formula known as the 'Droop Quota' is used.
This is calculated by dividing the total number of valid voting papers cast, by the number of seats to be filled plus one, and then adding one.
Candidates who exceed the quota are elected straightaway.
Surplus votes, i.e. those above the quota, are then transferred to the other candidates.
If any seats then remain to be filled, the lowest-ranked candidates are eliminated and their second and lower preferences are redistributed to the remaining candidates.
The process continues in this way until all the seats are filled.
In the European election, with just three seats to be elected, the counting process may only last a few rounds.
In local elections, where most councils have 40 seats and Belfast has 60, many more rounds of counting will take place to decide the outcome.
Each council is divided into District Electoral Areas (DEAs), which count the ballots for councillors representing that particular area.
To illustrate how STV works - and some of the complications - here is how Northern Ireland's three MEPs were elected in 2009.
There were 484,572 valid votes cast, and three seats to be filled. The quota was set at 121,144 (that is 484,572÷(3+1)+1)
As Sinn Féin's Bairbre de Brun won enough first preference votes to exceed the quota, she was elected straightaway.
Her 'surplus' first preferences were 5,040 (126,184 - 121,144)
Under STV rules, because her 5,040 surplus was less than the gap between Steven Agnew and Ian Parsley, and also less than the difference of their votes combined and next placed candidate Jim Allister, Agnew and Parsley were eliminated and their votes transferred.
Still with us? We continue to the next round.
All of Agnew and Parsley's ballots were then checked for second preferences. The outcome was:
So after the second round, no other candidate had managed to exceed the quota.
Last placed Jim Allister was then eliminated, and his second preferences redistributed.
In this third round, Jim Nicholson received 37,942 transferred votes from Jim Allister, taking him over the quota and securing his European Parliament seat.
But in a final twist - even if Nicholson's 11,113 and Bairbre De Brun's 5,040 surplus votes had all gone to Alban Maginness, he would still not have reached Diane Dodds' total.
Therefore, Diane Dodds was declared winner of the third and final seat - despite not reaching the 121,144 quota.