Skip to content

Commit 2f1bdb3

Browse files
authored
[decimal] Implement the quantize() function (#44)
This pull request adds support for a new `quantize` function across various files and updates dependencies. The most important changes include the addition of the `quantize` function, updates to the `mojoproject.toml` file, and the inclusion of new benchmarks and tests. ### Addition of `quantize` function: * `src/decimojo/decimal.mojo`: Added the `quantize` method to the `Decimal` struct to allow quantizing a `Decimal` to a specified exponent. * `src/decimojo/rounding.mojo`: Implemented the `quantize` function, which rounds a value according to the exponent of the second operand. ### Updates to `mojoproject.toml`: * `mojoproject.toml`: Added the `max` dependency and included `test_quantize` and `bench_quantize` tasks. ### Inclusion of new benchmarks and tests: * `benches/bench.mojo`: Added `bench_quantize` to the list of benchmarks. * `src/decimojo/__init__.mojo`: Updated imports to include the new `quantize` function.
1 parent d9f52a0 commit 2f1bdb3

File tree

7 files changed

+1165
-20
lines changed

7 files changed

+1165
-20
lines changed

benches/bench.mojo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from bench_from_float import main as bench_from_float
77
from bench_from_string import main as bench_from_string
88
from bench_from_int import main as bench_from_int
99
from bench_round import main as bench_round
10+
from bench_quantize import main as bench_quantize
1011
from bench_comparison import main as bench_comparison
1112
from bench_exp import main as bench_exp
1213
from bench_ln import main as bench_ln
@@ -25,6 +26,7 @@ fn main() raises:
2526
bench_from_string()
2627
bench_from_int()
2728
bench_round()
29+
bench_quantize()
2830
bench_comparison()
2931
bench_exp()
3032
bench_ln()

0 commit comments

Comments
 (0)