[decimal] Implement true_divide for BigDecimal type + fix a bug in BigUInt.multiply
#70
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 significant changes to the BigInt and BigDecimal arithmetic operations, introducing new functionality and improving existing methods. The most important changes include adding true division functionality for BigDecimal, modifying scaling methods, and updating the handling of leading zeros in BigUInt operations.
Notably, this PR fixes a bug in
BigUInt.multiplywhere the carry is mistakenly skipped if a word of x2 is zero.BigDecimal Enhancements:
true_dividefunction to perform division with specified precision and rounding rules insrc/decimojo/bigdecimal/arithmetics.mojo.benches/bigdecimal/bench.mojo. [1] [2] [3]BigUInt Improvements:
remove_trailing_zeroswithremove_leading_empty_wordsto handle leading zeros more effectively in multiple functions acrosssrc/decimojo/biguint/arithmetics.mojo. [1] [2] [3] [4] [5]divmodfunction to usefloor_divideandsubtractfor quotient and remainder calculation insrc/decimojo/biguint/arithmetics.mojo.Codebase Simplification:
multiply_by_power_of_10toscale_up_by_power_of_10for clarity and consistency insrc/decimojo/biguint/arithmetics.mojo.floor_dividefunction insrc/decimojo/biguint/arithmetics.mojo. [1] [2]These changes enhance the arithmetic capabilities of BigDecimal and BigUInt, improve code clarity, and ensure more efficient handling of numerical operations.