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
2 changes: 1 addition & 1 deletion docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This is a to-do list for Yuhao's personal use.

- The `exp()` function performs slower than Python's counterpart in specific cases. Detailed investigation reveals the bottleneck stems from multiplication operations between decimals with significant fractional components. These operations currently rely on UInt256 arithmetic, which introduces performance overhead. Optimization of the `multiply()` function is required to address these performance bottlenecks, particularly for high-precision decimal multiplication with many digits after the decimal point.
- [x] (#31) The `exp()` function performs slower than Python's counterpart in specific cases. Detailed investigation reveals the bottleneck stems from multiplication operations between decimals with significant fractional components. These operations currently rely on UInt256 arithmetic, which introduces performance overhead. Optimization of the `multiply()` function is required to address these performance bottlenecks, particularly for high-precision decimal multiplication with many digits after the decimal point.
1 change: 1 addition & 0 deletions mojoproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test_round = "magic run package && magic run mojo test tests/test_round.mojo &&
test_creation = "magic run package && magic run mojo test tests/test_creation.mojo && magic run delete_package"
test_from_float = "magic run package && magic run mojo test tests/test_from_float.mojo && magic run delete_package"
test_from_string = "magic run package && magic run mojo test tests/test_from_string.mojo && magic run delete_package"
test_to_float = "magic run package && magic run mojo test tests/test_to_float.mojo && magic run delete_package"
test_comparison = "magic run package && magic run mojo test tests/test_comparison.mojo && magic run delete_package"
test_factorial = "magic run package && magic run mojo test tests/test_factorial.mojo && magic run delete_package"
test_exp = "magic run package && magic run mojo test tests/test_exp.mojo && magic run delete_package"
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/__init__.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #

"""
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/arithmetics.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements basic arithmetic functions for the Decimal type
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/comparison.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements comparison operations for the Decimal type
Expand Down
4 changes: 1 addition & 3 deletions src/decimojo/decimal.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements basic object methods for the Decimal type
Expand Down Expand Up @@ -967,7 +965,7 @@ struct Decimal(
The floating-point representation of this Decimal.
"""

var result = Float64(self.coefficient()) / (10 ** self.scale())
var result = Float64(self.coefficient()) / (Float64(10) ** self.scale())
result = -result if self.is_negative() else result

return result
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/exponential.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements exponential functions for the Decimal type
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/prelude.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #

"""
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/rounding.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements basic object methods for the Decimal type
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/rounding_mode.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #


Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/special.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements special functions for the Decimal type
Expand Down
2 changes: 0 additions & 2 deletions src/decimojo/utility.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# ===----------------------------------------------------------------------=== #
#
# DeciMojo: A fixed-point decimal arithmetic library in Mojo
# https://github.com/forFudan/DeciMojo
#
Expand All @@ -16,7 +15,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ===----------------------------------------------------------------------=== #
#
# Implements internal utility functions for the Decimal type
Expand Down
129 changes: 0 additions & 129 deletions tests/test_conversions.mojo

This file was deleted.

Loading
Loading