Enable customizable precision for allocations #1114
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.
Problem
Me and @spariev have found that the allocation logic fails to function properly with large arrays. In a real production scenario, we encountered a process freeze followed by an error.
The reason is that when the number of parts exceeds 15, there is an infinite number of digits after the decimal point.
Solution
The
generate
method has been refactored by renaming thewhole_amounts
parameter torounding_mode
for better clarity. This allows more flexible rounding options, supporting booleans and custom decimal precision.