Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DeciMojo is available in the [modular-community](https://repo.prefix.dev/modular

From the `magic` CLI, simply run ```magic add decimojo```. This fetches the latest version and makes it immediately available for import.

For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.2.0"```. Then run `magic install` to download and install the package.
For projects with a `mojoproject.toml`file, add the dependency ```decimojo = ">=0.3.0"```. Then run `magic install` to download and install the package.

For the latest development version, clone the [GitHub repository](https://github.com/forfudan/decimojo) and build the package locally.

Expand Down Expand Up @@ -216,7 +216,7 @@ If you find DeciMojo useful for your research, consider listing it in your citat
year = {2025},
title = {An arbitrary-precision decimal and integer mathematics library for Mojo},
url = {https://github.com/forfudan/decimojo},
version = {0.2.0},
version = {0.3.0},
note = {Computer Software}
}
```
Expand Down
40 changes: 23 additions & 17 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@

This is a list of RELEASED changes for the DeciMojo Package. For the unreleased changes, please refer to **[changelog_unreleased](https://zhuyuhao.com/decimojo/docs/changelog_unreleased.html)**.

## 15/04/2025 (v0.3.0)

DeciMojo v0.3.0 introduces the arbitrary-precision `BigDecimal` type with comprehensive arithmetic operations, comparisons, and mathematical functions (`sqrt`, `root`, `log`, `exp`, `power`). A new `tomlmojo` package supports test refactoring. Improvements include refined `BigUInt` constructors, enhanced `scale_up_by_power_of_10()` functionality, and a critical multiplication bug fix.

### ⭐️ New

- Implement the `BigDecimal` type with unlimited precision arithmetic.
- Implement basic arithmetic operations for `BigDecimal`: addition, subtraction, multiplication, division, and modulo.
- Implement comparison operations for `BigDecimal`: less than, greater than, equal to, and not equal to.
- Implement string representation and parsing for `BigDecimal`.
- Implement mathematical operations for `BigDecimal`: `sqrt`, `nroot`, `log`, `exp`, and `power` functions.
- Iimplement rounding functions.
- Implement a simple TOML parser as package `tomlmojo` to refactor tests (PR #63).

### 🦋 Changed

- Refine the constructors of `BigUInt` (PR #64).
- Improve the method `BigUInt.scale_up_by_power_of_10()` (PR #72).

### 🛠️ Fixed

- Fix a bug in `BigUInt` multiplication where the calcualtion of carry is mistakenly skipped if a word of x2 is zero (PR #70).

## 01/04/2025 (v0.2.0)

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.

DeciMojo division performance compared with Python's `decimal` module across versions:

| Division Operation | v0.1.0 vs Python | v0.2.0 vs Python | Improvement |
| --------------------------------- | ---------------- | ---------------- | ----------- |
| Integer division (no remainder) | 0.15× (slower) | 485.88× faster | 3239× |
| Simple decimal division | 0.13× (slower) | 185.77× faster | 1429× |
| Division with repeating decimal | 0.04× (slower) | 12.46× faster | 311× |
| Division by one | 0.15× (slower) | 738.60× faster | 4924× |
| Division of zero | 1820.50× faster | 1866.50× faster | 1.03× |
| Division with negative numbers | 0.11× (slower) | 159.32× faster | 1448× |
| Division by very small number | 0.21× (slower) | 452.75× faster | 2156× |
| High precision division | 0.005× (slower) | 15.19× faster | 3038× |
| Division resulting in power of 10 | 0.21× (slower) | 619.00× faster | 2948× |
| Division of very large numbers | 0.06× (slower) | 582.86× faster | 9714× |

_Note: Benchmarks performed on Darwin 24.3.0, arm processor with Python 3.12.9. The dramatic performance improvements in v0.2.0 come from completely rewriting the division algorithm using Mojo 25.2's UInt128 implementation. While v0.1.0 was generally slower than Python for division operations (except for division of zero), v0.2.0 achieves speedups of 12-1866× depending on the specific scenario._

### ⭐️ New

- Add comprehensive `BigInt` and `BigUInt` implementation with unlimited precision integer arithmetic.
Expand Down
8 changes: 0 additions & 8 deletions docs/changelog_unreleased.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# DeciMojo unreleased changelog

This is a list of UNRELEASED changes for the DeciMojo Package. For the released changes, please refer to **[changelog](https://zhuyuhao.com/decimojo/docs/changelog.html)**.

### ⭐️ New

- Add comprehensive `BigDecimal` implementation with unlimited precision arithmetic.

### 🛠️ Fixed

- Fix a bug in `BigUInt` multiplication where the calcualtion of carry is mistakenly skipped if a word of x2 is zero (PR #70).
12 changes: 6 additions & 6 deletions docs/readme_zht.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ DeciMojo 爲 Mojo 提供了全面的定點數和整數運算庫,專爲處理

核心類型包括:

- 一種 128 位定點數實現 (`Decimal`) 支持最多 29 位有效數字,小數點後最多 28 位數字[^fixed]。它具有完整的數學函數集,包括對數、指數、開方和三角函數運算。
- 一種基於 10 進制的任意精度有符號整數類型 (`BigInt`) 和任意精度無符號整數類型 (`BigUInt`)[^integer],支持無限位數。它具有全面的算術運算、比較功能,並能高效支持超大整數計算。

該庫正在擴展,計劃包含支持任意精度的 `BigDecimal` 類型[^arbitrary],允許進行無限位數和小數位的計算。這些擴展目前正在積極開發中。
- 128 位定點數 (`Decimal`),支持最多 29 位有效數字,小數點後最多 28 位數字[^fixed]。
- 任意精度定點數 (`BigDecimal`) ,允許進行無限位數和小數位的計算。
- 基於 10 進制的任意精度有符號整數 (`BigInt`) 和任意精度無符號整數 (`BigUInt`)[^integer],支持無限位數。它具有全面的算術運算、比較功能,並能高效支持超大整數計算。

## 安裝

DeciMojo 可在 [modular-community](https://repo.prefix.dev/modular-community) 包倉庫中獲取。您可以使用以下任一方法進行安裝:

從 `magic` CLI,只需運行 ```magic add decimojo```。這會獲取最新版本並使其立即可用於導入。

對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.2.0"```。然後運行 `magic install` 來下載並安裝包。
對於帶有 `mojoproject.toml` 文件的項目,添加依賴 ```decimojo = ">=0.3.0"```。然後運行 `magic install` 來下載並安裝包。

如需最新的開發版本,請克隆 [GitHub 倉庫](https://github.com/forfudan/decimojo) 並在本地構建包。

| `decimojo` | `mojo` |
| ---------- | ------ |
| v0.1.0 | >=25.1 |
| v0.2.0 | >=25.2 |
| v0.3.0 | >=25.2 |

## 快速入門

Expand Down Expand Up @@ -216,7 +216,7 @@ DeciMojo 相較於 Python 的 `decimal` 模塊提供了卓越的性能,同時
year = {2025},
title = {DeciMojo: A fixed-point decimal arithmetic library in Mojo},
url = {https://github.com/forfudan/decimojo},
version = {0.2.0},
version = {0.3.0},
note = {Computer Software}
}
```
Expand Down
3 changes: 1 addition & 2 deletions mojoproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ license = "Apache-2.0"
name = "decimojo"
platforms = ["osx-arm64", "linux-64"]
readme = "README.md"
version = "0.2.0"
version = "0.3.0"

[dependencies]
max = "==25.2"
mpmath = ">=1.3.0,<2"

[tasks]
# format the code
Expand Down