Commit a33d891
authored
This pull request includes several changes across different files to
optimize the performance of `multiply` and `exp` and improve the
functionality and readability of the codebase. The changes involve
importing and utilizing new modules, refactoring functions for better
clarity, and fixing minor issues.
This PR significantly improve the speed when multiplying two decimals
with many digits after the decimal points (>20). This indirectly
enhances the performance of `exp` significantly.
### Utility Functions:
* Refactored the `truncate_to_max` function to use `power_of_10` for
calculating powers of ten.
* Optimize `number_of_digit` by using direct lookup instead of
calculating ad hoc.
### Arithmetic Functions:
* Refactored the `add` and `multiply` functions for better readability
and efficiency. This includes using `Decimal.from_uint128` for creating
`Decimal` objects and improving the handling of scale and rounding.
1 parent d30418e commit a33d891
File tree
7 files changed
+498
-166
lines changed- .github/workflows
- benches
- src/decimojo
- tests
7 files changed
+498
-166
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
0 commit comments