Splitting $10.00 three ways loses a cent (#52) - #58
Closed
Param-Harrison wants to merge 3 commits into
Closed
Param-Harrison wants to merge 3 commits into
Param-Harrison wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #52
Summary
splitCentsnow gives the leftover cents to the first members, following the handling-money remainder rule, so shares always add up to the total. For example, 1000 split three ways is now 334/333/333, not 333/333/333. Onlysrc/money/cents.tsandtests/money.test.tschanged.Acceptance criteria
splitCents(1000, ["a","b","c"])→{a:334, b:333, c:333}bun test tests/money.test.ts -t "gives the remainder cents to the first members"+1shares going to the first membersbun test tests/money.test.ts -t "shares always sum to the total"(1000/3, 101/5, 1/3, 2/3, 999/7, 1003/4)splitCentstests unchanged and passingbun test tests/money.test.ts;git diff --numstaton the test file shows 30 insertions, 0 deletionsokbun run .claude/skills/handling-money/scripts/check-cents.ts[ok ]make checkNon-goals respected
src/money/cents.tsandtests/money.test.tschange):git diff --name-only 934ab00 HEADlists just those two files.splitCentssignature and return type are unchanged.formatCents,parseCentsandsumCentsare byte-identical.Math.floorand integer arithmetic are used.leaves negative and non-integer totals floored as beforecovers this.The test that bites
tests/money.test.ts›splitCents›gives the remainder cents to the first members(alsoshares always sum to the total)main: with the pre-fixsrc/money/cents.ts(git checkout 934ab00 -- src/money/cents.ts),bun test tests/money.test.tsfails withExpected: {a:334,...} Received: {a:333,...}andExpected: 1000, Received: 999bun test tests/money.test.ts -t "gives the remainder cents to the first members"→1 pass, 0 failGate line
The optional
auditgate fails on hono advisories that were already there before this change. They are out of scope for this issue.Protected paths touched
noneReviewer findings addressed
src/money/cents.tsin the working tree. This was transient: the verifier was running at the same time and its revert-and-restore step staged the old file on purpose, then restored it. After both finished,git status --shortwas empty,bun test tests/money.test.tsgave 9 pass and 0 fail, andmake checkwas green. The committed diff was not affected. There were no other findings. Full details are in the verdict comment on Splitting $10.00 three ways loses a cent #52.Human checklist
🤖 Generated with Claude Code