Skip to content

Conversation

@forfudan
Copy link
Owner

@forfudan forfudan commented Jul 30, 2025

This pull request introduces significant improvements and error handling enhancements for arithmetic operations in the BigInt and BigUInt types. Key changes include the removal of the raises keyword from function signatures, the addition of structured error handling using custom error types, and improvements to the implementation of arithmetic operations to ensure correctness and maintainability.

Improved Error Handling

  • Introduced custom error types such as DeciMojoError, OverflowError, and ZeroDivisionError across the codebase for more structured and descriptive error reporting. For example, division and modulo operations now raise ZeroDivisionError when dividing by zero.

  • Replaced generic error messages with detailed exceptions that include contextual information such as the file, function, and previous error, improving debugging and traceability.

Update TOML parser

  • Updated the TOML parser by allowing parsing CRLF TOML files.

Enhancements to Arithmetic Operations

  • Removed the raises keyword from all arithmetic function signatures in src/decimojo/bigint/arithmetics.mojo and src/decimojo/biguint/arithmetics.mojo. This simplifies the function definitions while maintaining error handling through explicit exceptions.

  • Updated the add_inplace, subtract, and multiply functions in src/decimojo/bigint/arithmetics.mojo to use helper functions like negative and subtract_inplace_no_check for better clarity and modularity.

Updates to BigInt Struct Methods

  • Updated operator overloading methods (e.g., __add__, __sub__, __mul__) in src/decimojo/bigint/bigint.mojo to remove the raises keyword and include structured error handling where applicable.

  • Enhanced in-place operators like __iadd__ and __isub__ to directly call the updated arithmetic functions, ensuring consistency with the new error handling approach.

Codebase-Wide Improvements

  • Added .gitattributes configuration to enforce LF (Unix-style) line endings for consistency across the project.

  • Improved modularity by importing DeciMojoError in relevant files such as src/decimojo/bigint/bigint.mojo and src/decimojo/biguint/arithmetics.mojo.
    These changes collectively improve the robustness, readability, and maintainability of the codebase while introducing a more structured approach to error handling for arithmetic operations.

@forfudan forfudan merged commit baf2bc4 into main Jul 31, 2025
1 check passed
@forfudan forfudan deleted the work branch July 31, 2025 18:20
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