Anti-Harassment Tools/SecurePoll Improvements/Test Results/Precision

Background
There are various calculations that get done when tallying an STV election. All of these could be affected by arithmetic precision bugs.

Due to the limited precision of any computer arithmetic, we cannot guarantee our results will always be precise. I have been trying to test the sort of precision errors we can possibly expect, and whether they are acceptable.

Caveat: I am not a numerical analyst, so I am not an expert in doing this sort of analysis.

Calculations/possible sources of numerical error (not exhaustive):
 * Droop quota
 * Keep factors for each candidate
 * Vote distribution
 * Surplus
 * Total votes

Vote distribution
In STV, each vote is divided up and given to candidates based on a formula...

Internal consistency
In each round we calculate each candidates previous rounds votes, votes earned in that round and total votes.

By subtracting the previous rounds votes from the total votes and comparing to the votes earned that round, this give us a particular measure of precision (exactly the significance of this measure, I don't know).

Based on the large amounts of test data I had locally, the biggest difference I found was 1.35173650051E-10 (this result from this election).

Order of operands
A candidate's vote distribution is calculated like:

The order the operands appear in the calculation can affect the precision of the answer.

For example, to 16 decimal places in PHP:

The order of operands can vary from candidate to candidate.

For example, in this election, candidates 1 and 3 have slightly different "earned" votes in round 3 (see here), even though this number should be a the same (both candidates have exactly the same number of votes, including 2nd preferences). I suspect (although I cannot know for sure) that this is due to different orders of operands. The difference does not impact the candidates "total" votes, nor the election outcome.

I don't know if we can predict the effect, nor algorithmically decide which order of operands will give the "best" results.

Misc
The total votes are also calculated at the same time, which could affect the droop quota.