Skip to content

Conversation

@forfudan
Copy link
Owner

This pull request introduces several updates to the decimojo library, focusing on improving numerical operations with BigUInt and BigDecimal types. Key changes include replacing a placeholder function with a more optimized implementation, adding debug assertions to enforce non-negative input constraints, and introducing a new utility function for division by powers of a billion.

Improvements to numerical operations:

  • Optimized division by powers of a billion: Replaced the placeholder call to floor_divide_by_power_of_ten with the newly implemented floor_divide_by_power_of_billion in true_divide_fast for better performance.

  • New utility function: Added floor_divide_by_power_of_billion, which efficiently removes the last n words of a BigUInt, equivalent to dividing by (10^9)^n. This function handles edge cases and includes debug assertions.

Input validation and robustness:

  • Debug assertions for non-negative inputs: Added debug assertions to ensure that input parameters n are non-negative in functions such as multiply_by_power_of_ten, multiply_inplace_by_power_of_ten, multiply_by_power_of_billion, multiply_inplace_by_power_of_billion, and floor_divide_by_power_of_ten. These assertions improve code reliability during development and testing.

  • Updated handling of zero or negative n: Modified behavior in several functions to return the input unchanged when n <= 0, ensuring consistent and predictable results.

These changes collectively enhance the library's performance, robustness, and maintainability.

@forfudan forfudan merged commit fca5021 into main Aug 1, 2025
1 check passed
@forfudan forfudan deleted the work branch August 1, 2025 16:49
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