For more information, please visit the repo of DeciMojo: https://github.com/forfudan/decimojo
Version 0.2.0 marks a significant expansion of DeciMojo with the introduction of BigInt
and BigUInt
types, providing unlimited precision integer arithmetic to complement the existing fixed-precision Decimal
type. Core arithmetic functions for the Decimal
type have been completely rewritten using Mojo 25.2’s UInt128
, delivering substantial performance improvements. This release also extends mathematical capabilities with advanced operations including logarithms, exponentials, square roots, and n-th roots for the Decimal
type. The codebase has been reorganized into a more modular structure, enhancing maintainability and extensibility. With comprehensive test coverage, improved documentation in multiple languages, and optimized memory management, v0.2.0 represents a major advancement in both functionality and performance for numerical computing in Mojo.
New
- Add
BigInt
andBigUInt
implementation with unlimited precision integer arithmetic. - Implement full arithmetic operations for
BigInt
andBigUInt
: addition, subtraction, multiplication, division, modulo and power operations. - Support both floor division (round toward negative infinity) and truncate division (round toward zero) semantics for mathematical correctness.
- Add complete comparison operations for
BigInt
with proper handling of negative values. - Implement efficient string representation and parsing for
BigInt
andBigUInt
. - Add advanced mathematical operations for
Decimal
: square root and n-th root. - Add logarithm functions for
Decimal
: natural logarithm, base-10 logarithm, and logarithm with arbitrary base. - Add exponential function and power function with arbitrary exponents for
Decimal
.
Changed
- Completely re-write the core arithmetic functions for
Decimal
type usingUInt128
introduced in Mojo 25.2. This significantly improves the performance ofDecimal
operations. - Improve memory management system to reduce allocations during calculations.
- Reorganize codebase with modular structure (decimal, arithmetics, comparison, exponential).
- Enhance
Decimal
comparison operators for better handling of edge cases. - Update internal representation of
Decimal
for better precision handling.
Removed
- Remove deprecated legacy string formatting methods.
- Remove redundant conversion functions that were replaced with a more unified API.
Fixed
- Fix edge cases in division operations with zero and one.
- Correct sign handling in mixed-sign operations for both
Decimal
. - Fix precision loss in repeated addition/subtraction operations.
- Correct rounding behavior in edge cases for financial calculations.
- Address inconsistencies between operator methods and named functions.
Documentation and testing
- Add comprehensive test suite for
BigInt
andBigUInt
with over 200 test cases covering all operations and edge cases. - Create detailed API documentation for both
Decimal
andBigInt
. - Add performance comparison benchmarks between DeciMojo and Python’s decimal/int implementation.
- Update multi-language documentation to include all new functionality (English and Chinese).
- Include clear explanations of division semantics and other potentially confusing numerical concepts.