# DeciMojo v0.2 for Mojo 25.2 - decimal and integer mathematics library

**URL:** <https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153>\
**Category:** Community Showcase\
**Created:** [March 27, 2025, 6:09pm UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153 "2025-03-27T18:09:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![forfudan](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/forfudan/32/925_2.png) [@forfudan](https://forum.modular.com/u/forfudan)\
**Post date:** [March 27, 2025, 6:09pm UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153/1 "2025-03-27T18:09:46Z")

</div>

For more information, please visit the repo of DeciMojo: [https://github.com/forfudan/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` and `BigUInt` implementation with unlimited precision integer arithmetic.
- Implement full arithmetic operations for `BigInt` and `BigUInt`: 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` and `BigUInt`.
- 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 using `UInt128` introduced in Mojo 25.2. This significantly improves the performance of `Decimal` 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` and `BigUInt` with over 200 test cases covering all operations and edge cases.
- Create detailed API documentation for both `Decimal` and `BigInt`.
- 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.

---

<div class="post-metadata">

**Author:** ![bgreni](https://avatars.discourse-cdn.com/v4/letter/b/e495f1/32.png) [@bgreni](https://forum.modular.com/u/bgreni)\
**Post date:** [March 27, 2025, 6:18pm UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153/2 "2025-03-27T18:18:12Z")

</div>

Wow, awesome work. Very excited to see a `BigInt` type here!

---

<div class="post-metadata">

**Author:** ![forfudan](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/forfudan/32/925_2.png) [@forfudan](https://forum.modular.com/u/forfudan)\
**Post date:** [March 28, 2025, 8:42pm UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153/3 "2025-03-28T20:42:10Z")

</div>

Thanks! BigInt is quite important in many situations.

---

<div class="post-metadata">

**Author:** ![forfudan](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/forfudan/32/925_2.png) [@forfudan](https://forum.modular.com/u/forfudan)\
**Post date:** [June 16, 2025, 11:59am UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153/4 "2025-06-16T11:59:24Z")

</div>

DeciMojo v0.3.1 is released with the introduction of the `BigDecimal` type. It also supports Mojo v25.3 and pixi now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [December 13, 2025, 12:00pm UTC](https://forum.modular.com/t/decimojo-v0-2-for-mojo-25-2-decimal-and-integer-mathematics-library/1153/5 "2025-12-13T12:00:04Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
