Repository navigation
Keep a rounded cent that carries into the next unit - #22
Merged
Merged
Conversation
Price::parse("1.999") returned EUR 1.00. The rounded fraction 1.00 was read as empty cents.
toonvandenbos
approved these changes
Oct 9, 2026
Member
|
Thank you! |
Contributor
Author
|
Thanks for merging this. The rounded cent carrying into the next unit is the part I wanted kept. |
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.
Summary
Price::parse("1.999", "EUR")returnedEUR 1.00. The cents are rounded to two places, and0.999rounds to1.00. That leading1was thrown away, so the amount stayed1.00. It is now2.00.0.999is1.00.4.995is5.00.-1.999is-2.00.9.996is10.00.4.005is still4.01.12.50is still12.50.Test plan
./vendor/bin/pest tests/Unit/ParsesMonetaryStringsTest.php. Before the fix,1.999wasEUR 1.00.Made with Cursor