Skip to content

Conversation

@forfudan
Copy link
Owner

@forfudan forfudan commented Jul 9, 2025

This pull request introduces several enhancements and modifications to the BigUInt and BigDecimal arithmetic operations. Key changes include the introduction of optimized carry normalization methods, improvements to division algorithms, and the addition of a specialized multiplication function for small values. These changes aim to improve performance, readability, and maintainability of the codebase.

Enhancements to Carry Normalization:

  • Renamed and refactored normalize_carries to normalize_carries_lt_2_bases and introduced normalize_carries_lt_4_bases for handling specific ranges of word values during arithmetic operations. These methods ensure efficient normalization of carries based on the range of input values. [1] [2]

Optimizations for Multiplication:

  • Added a new function multiply_inplace_by_uint32_le_4 to handle multiplication by small integers (0–4) more efficiently using SIMD instructions and specialized carry normalization. This is integrated into the existing multiply_inplace_by_uint32 function. [1] [2]

Improvements to Division Algorithms:

  • Replaced normalization_factor with ndigits_to_shift for better clarity in division-related functions. Updated the logic for calculating normalization shifts and gap ratios for more accurate and efficient division processes. [1] [2] [3]
  • Refactored the calculate_normalization_factor function to calculate_number_of_shifted_digits_for_normalization for better semantic clarity.

Code Simplifications:

  • Simplified the floor_divide_inplace_by_2 function by removing redundant carry logic and replacing it with a more concise implementation using a boolean flag for carry tracking.

Documentation and Naming Improvements:

  • Updated function and parameter names, as well as docstrings, for improved clarity and consistency across the codebase (e.g., floor_divide_three_by_two now refers to "parts" instead of "words").

These changes collectively enhance the precision, performance, and maintainability of the arithmetic operations in the decimojo library.

@forfudan forfudan merged commit 5911784 into main Jul 9, 2025
1 check passed
@forfudan forfudan deleted the work branch July 9, 2025 23:09
forfudan added a commit that referenced this pull request Jul 9, 2025
forfudan added a commit that referenced this pull request Jul 9, 2025
forfudan added a commit that referenced this pull request Jul 11, 2025
forfudan added a commit that referenced this pull request Jul 14, 2025
forfudan added a commit that referenced this pull request Jul 15, 2025
forfudan added a commit that referenced this pull request Jul 18, 2025
forfudan added a commit that referenced this pull request Jul 24, 2025
forfudan added a commit that referenced this pull request Jul 26, 2025
forfudan added a commit that referenced this pull request Jul 31, 2025
forfudan added a commit that referenced this pull request Aug 3, 2025
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