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.
Hello there....
I have an external API that executes some calculations and returns a result as a report. One of these results happened to be an amount that was a very very tiny one.
2.8865798640254e-15
My code that consumes the API parses this value to a Money object automatically by doing:
I know that there is no actual currency that could represent a so tiny amount and it is practically zero (maybe in some bitcoins it have some value).
So the code above throws exception because the value is converted to a string in this form:
2.8865798640254e-15
and this does not pass the expression inside the DecimalParser. For now in order to stop getting exception I had to do a quick solution to round the number to 7 decimals and then pass it inside the parser and it feels kinda hackish.As a better solution I could create something like a
ExponentialParser
and pass it inside anAggregateParser
but before going into that I felt that I should ask if you believe that this should be handled by the DecimalParser and not by a different parser...If yes maybe I could implement the changes on this PR.
For my case above I have added a test case to check it.