Skip to content

Conversation

@forfudan
Copy link
Owner

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.multiply where the carry is mistakenly skipped if a word of x2 is zero.

BigDecimal Enhancements:

  • Added true_divide function to perform division with specified precision and rounding rules in src/decimojo/bigdecimal/arithmetics.mojo.
  • Updated the benchmarks to include the new division operation in benches/bigdecimal/bench.mojo. [1] [2] [3]

BigUInt Improvements:

  • Replaced remove_trailing_zeros with remove_leading_empty_words to handle leading zeros more effectively in multiple functions across src/decimojo/biguint/arithmetics.mojo. [1] [2] [3] [4] [5]
  • Simplified the divmod function to use floor_divide and subtract for quotient and remainder calculation in src/decimojo/biguint/arithmetics.mojo.

Codebase Simplification:

  • Renamed multiply_by_power_of_10 to scale_up_by_power_of_10 for clarity and consistency in src/decimojo/biguint/arithmetics.mojo.
  • Removed unnecessary cases and optimized the floor_divide function in src/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.

@forfudan forfudan merged commit 8389aa3 into main Mar 30, 2025
1 check failed
@forfudan forfudan deleted the div branch March 30, 2025 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants