[decimal] Implement round() for BigDecimal
#83
Merged
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.
This pull request includes several changes to the BigDecimal library, focusing on adding new functionalities, improving existing methods, and making the code more robust. The most important changes include the addition of new arithmetic operations, enhancements to rounding and comparison methods, and updates to the benchmarking script.
New Arithmetic Operations:
truncate_divideandtruncate_modulofunctions tosrc/decimojo/bigdecimal/arithmetics.mojofor performing truncated division and modulo operations.__floordiv__andtruncate_dividemethods in theBigDecimalstruct to support floor division. [1] [2]Enhancements to Rounding:
roundfunction insrc/decimojo/bigdecimal/rounding.mojoto handle rounding with different modes and precisions.__round__methods to theBigDecimalstruct to support rounding with specified decimal places and rounding modes.Improvements to Comparison Methods:
raiseskeyword from several comparison functions insrc/decimojo/bigdecimal/comparison.mojoto simplify their signatures. [1] [2] [3]Updates to Benchmarking Script:
roundfunction inbenches/bigdecimal/bench.mojoand updated the script to include the new benchmark. [1] [2] [3] [4]Other Changes:
BigDecimalstruct to implement additional traits and improved thescale_up_by_power_of_10function insrc/decimojo/biguint/arithmetics.mojoto handle non-positive values. [1] [2] [3] [4] [5]These changes enhance the functionality and robustness of the BigDecimal library, making it more versatile and easier to use.