Page MenuHomePhabricator

SecurePoll: Numbers less than 0.0001 appear as 0 on tally page
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

When a number is less than 0.0001, it appears as 0 in the tally page.

I think Message::numParams converts numbers less than 0.0001 to 0 (and have confirmed this by var_dumping output in PHPUnit).

For example, round 26 in this election (tally page on beta, tally page locally) displays 257.000220 - 0 = 257.000133. The 0 should be 0.000087.

Steps to reproduce problem
Environment

Wiki(s): https://vote.wikimedia.beta.wmflabs.org 3.0.0 (b7a4ccb) 06:16, 1 September 2021.

Screenshots (if applicable):

small_number.png (142×807 px, 22 KB)

Event Timeline

Change 715944 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/SecurePoll@master] stvTallier: Format votes earned

https://gerrit.wikimedia.org/r/715944

Change 715799 had a related patch set uploaded (by Phuedx; author: TsepoThoabala):

[mediawiki/extensions/SecurePoll@master] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/715799

Change 715944 abandoned by Phuedx:

[mediawiki/extensions/SecurePoll@master] stvTallier: Format votes earned

Reason:

Squashed into I218a200157d.

https://gerrit.wikimedia.org/r/715944

Change 715799 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@master] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/715799

We now display numbers as small as 0.000001 (see round 13 of https://vote.wikimedia.beta.wmflabs.org/wiki/Special:SecurePoll/tally/1691).

Note that, on the tally page, the number of votes gained/lost each round is calculated by subtracting the previous round's votes from the current round's. This is done after we have rounded the current and previous round's votes to 6 decimal places.

This can obviously lead to rounding errors. For example, in round 13, rounded to 8 decimal places, candidate 9's vote goes from 205.00000048 to 205.00000058 for a change of 1E-7. But, rounded to 6 decimal places, the vote goes from 205 to 205.000001 for a change of 1E-6.

round_13.png (311×974 px, 61 KB)

If the current and previous round's votes are identical to 6 decimal places, we don't display any votes gained/lost. For example, in round 12, rounded to 8 decimal places, candidate 9's vote goes from 205.00000038 to 205.00000048 for a change of 1E-7. But, rounded to 6 decimal places, the votes are both 205.

round_12.png (306×972 px, 59 KB)

I believe the votes gained/lost is the only calculation the tally page does, and only for the purpose of display. Everything else, including elected and eliminated candidates, total votes each candidate has each round, quota and keep factors, is taken from the tally results (rounded to 6 decimal places).

Test Environment: https://vote.wikimedia.beta.wmflabs.org SecurePoll 3.0.0 (cdd701e) 06:21, 6 September 2021.

Change 719166 had a related patch set uploaded (by Tim Starling; author: TsepoThoabala):

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.21] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/719166

Change 719166 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.21] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/719166