Skip to content

#779: round the total once, not every line of the bill - #793

Open
gemshrine wants to merge 3 commits into
zerocracy:masterfrom
gemshrine:779-round-the-total
Open

gemshrine wants to merge 3 commits into
zerocracy:masterfrom
gemshrine:779-round-the-total

Conversation

@gemshrine

Copy link
Copy Markdown
Contributor

Fixes #779.

Bill#points rounded every line on its own and then added them up, so a bylaw with a fractional rate paid something other than its own text promises, once per clause. resolved-bug-was-rewarded says "deduct 0.5 points for each day of delay", and a one-day delay cost a whole point, while one day and two days cost exactly the same. Float#round rounds half away from zero, so the bias was always against the contributor.

The total is now the rounded sum instead of the sum of rounded parts.

That alone would have broken the invariant test_lines_add_up_to_the_total pins, so the per-line figures are apportioned: each line is rounded on its own, and the difference against the total goes to the lines with the largest remainders. The numbers in the greeting still add up to the number in front of them, and a clause that ends up worth nothing is no longer listed, which also takes away the +0 that used to be printed for a negative clause.

One more thing the issue names: a ${...} variable holding a float was interpolated raw, so the greeting carried sixteen digits of 0.9791666666666666. It is now formatted to two decimals when it is not whole.

For anger 1, love 2, paranoia 4 the delay penalty goes from 1/1/2/3/4 points at 1/2/3/5/7 days to 0/1/1/2/3, which is what "0.5 per day" adds up to.

Four tests, all failing on master.

yegor256 commented Sep 7, 2026

Copy link
Copy Markdown
Member

CI is green, but I am not merging this without your look. It changes the totals every bylaw pays (the delay penalty goes 1/1/2/3/4 → 0/1/1/2/3 on 1, 2, 4), and the largest-remainder apportionment it adds to keep test_lines_add_up_to_the_total true is new arithmetic in the part of the code that decides money.

Assigning to @yegor256.


Generated by Claude Code

@yegor256 yegor256 self-assigned this Sep 7, 2026

yegor256 commented Sep 8, 2026

Copy link
Copy Markdown
Member

CI is green and the reasoning holds, but this changes what contributors are actually paid, so I would rather not merge it unreviewed.

Two things a human should sign off on:

  1. points now rounds the sum once instead of rounding each line, so an existing bylaw pays a different number for the same inputs — { hoc: 78, comments: 7, self: 0 } moves from 12 to 13 in the fixture.
  2. portions is a new largest-remainder distribution invented here, and greeting now hides any line that rounds to zero. That is a presentational choice with a payout attached: a penalty of -0.4 disappears from the explanation while still pulling the total down.

Both look correct to me; neither is something I want to decide on your behalf. Assigning to @yegor256.


Generated by Claude Code

Copy link
Copy Markdown
Member

The apportioning approach here makes sense to me, but it's conflicting with master now, so it needs a rebase. Requesting a review too given it touches how every bill is totaled.


Generated by Claude Code

@yegor256
yegor256 self-requested a review September 27, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Points are rounded per clause before they are summed, so a half-point penalty costs a whole point

2 participants