Commit 7489776
authored
[decimal] Implement a subtraction function for
This pull request includes several changes to the
`benches/bigdecimal/bench.mojo`, `mojoproject.toml`, and
`src/decimojo/bigdecimal/arithmetics.mojo` files to add new
functionality and improve the codebase. The most important changes
include adding a new subtraction benchmark, renaming benchmark commands,
and implementing a subtraction function for `BigDecimal`.
### New functionality:
* Added a new subtraction benchmark by importing
`bench_bigdecimal_subtract` and updating the benchmark commands in
`benches/bigdecimal/bench.mojo`.
[[1]](diffhunk://#diff-96175f1000f81fe074f70a9adc4b39cd3f2dac8e85d30aa7efed9fc02b46e5ecR2)
[[2]](diffhunk://#diff-96175f1000f81fe074f70a9adc4b39cd3f2dac8e85d30aa7efed9fc02b46e5ecR12)
[[3]](diffhunk://#diff-96175f1000f81fe074f70a9adc4b39cd3f2dac8e85d30aa7efed9fc02b46e5ecR21-R25)
* Implemented the `subtract` function for `BigDecimal` in
`src/decimojo/bigdecimal/arithmetics.mojo`, including handling zero
operands and ensuring operands have the same scale.
### Codebase improvements:
* Renamed benchmark commands in `mojoproject.toml` for consistency and
clarity.
* Added notes to the `add` function in
`src/decimojo/bigdecimal/arithmetics.mojo` to clarify its behavior and
result properties.
* Added the `__sub__` method to the `BigDecimal` struct in
`src/decimojo/bigdecimal/bigdecimal.mojo` to support subtraction using
the new `subtract` function.BigDecimal (#67)1 parent 23f2e07 commit 7489776
File tree
6 files changed
+812
-4
lines changed- benches/bigdecimal
- src/decimojo
- bigdecimal
- biguint
6 files changed
+812
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
0 commit comments