Skip to content

Conversation

@forfudan
Copy link
Owner

@forfudan forfudan commented Jul 4, 2025

This pull request introduces significant enhancements to the BigDecimal module, focusing on trigonometric functionality, precision handling, and modular arithmetic. It also updates documentation and test cases to support these changes. The most important changes include the addition of sin and cos functions, improvements to rounding precision methods, and modular arithmetic support.

Trigonometric Functionality Enhancements:

  • Added sin and cos functions to struct BigDecimal, with range reduction and Taylor series implementations for accurate calculations. These functions handle edge cases for π-related values and ensure high precision. (src/decimojo/bigdecimal/bigdecimal.mojo src/decimojo/bigdecimal/bigdecimal.mojoR765-R774, src/decimojo/bigdecimal/trigonometric.mojo F4fb1110L30R321)
  • Updated arctan function to use round_to_precision for consistent precision handling and added intermediate result handling for better readability. (src/decimojo/bigdecimal/trigonometric.mojo F4fb1110L56R355)

Precision Handling Improvements:

  • Replaced round with round_to_precision across multiple functions, adding options to remove extra digits due to rounding and prevent trailing zeros. (src/decimojo/bigdecimal/constants.mojo F7b2c265L166R322, src/decimojo/bigdecimal/rounding.mojo src/decimojo/bigdecimal/rounding.mojoL102-R104)
  • Added detailed notes in the round_to_precision method to clarify the behavior of precision-related parameters. (src/decimojo/bigdecimal/bigdecimal.mojo src/decimojo/bigdecimal/bigdecimal.mojoR848-R854)

Modular Arithmetic Support:

Documentation Updates:

  • Expanded documentation in docs/internal_notes.md to include examples and precision comparisons for sin functionality, highlighting discrepancies between Decimojo, WolframAlpha, and mpmath. (docs/internal_notes.md docs/internal_notes.mdL5-R16)

Test Case Enhancements:

@forfudan forfudan merged commit 053934d into main Jul 4, 2025
1 check passed
@forfudan forfudan deleted the work branch July 4, 2025 19:50
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