Skip to content

Keep a rounded cent that carries into the next unit - #22

Merged
toonvandenbos merged 1 commit into
whitecube:3.xfrom
SashaMIT:codered-cent-carry
Oct 9, 2026
Merged

toonvandenbos merged 1 commit into
whitecube:3.xfrom
SashaMIT:codered-cent-carry

Conversation

@SashaMIT

Copy link
Copy Markdown
Contributor

Summary

Price::parse("1.999", "EUR") returned EUR 1.00. The cents are rounded to two places, and 0.999 rounds to 1.00. That leading 1 was thrown away, so the amount stayed 1.00. It is now 2.00.

0.999 is 1.00. 4.995 is 5.00. -1.999 is -2.00. 9.996 is 10.00. 4.005 is still 4.01. 12.50 is still 12.50.

Test plan

  • ./vendor/bin/pest tests/Unit/ParsesMonetaryStringsTest.php. Before the fix, 1.999 was EUR 1.00.

Made with Cursor

Price::parse("1.999") returned EUR 1.00. The rounded fraction 1.00 was read as empty cents.
@toonvandenbos
toonvandenbos merged commit 571cb6e into whitecube:3.x Oct 9, 2026
3 checks passed
@toonvandenbos

Copy link
Copy Markdown
Member

Thank you!

@SashaMIT

SashaMIT commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging this. The rounded cent carrying into the next unit is the part I wanted kept.

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.

2 participants