-
Notifications
You must be signed in to change notification settings - Fork 1
[decimal] Re-write from_string() constructor and improve the performance
#26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Owner
Author
|
Before |
Owner
Author
|
After: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request:
from_string(). This significantly improves the performance (x100) and can handle different errors.round_to_keep_first_n_digitsfunction which may falsely round-up in round-half-to-even mode. This is caused by an implicit type conversion which makes the value unsigned.Decimal.from_string()method.Decimal.from_string()method.Re-writes Decimal constructor from String:
from_string(). Then__init__calls this method.Codebase improvements:
round_to_keep_first_n_digitsfunction insrc/decimojo/utility.mojoto use explicit type casting forcutoff_value.Addition of comprehensive tests:
tests/test_from_string.mojowith 50 test cases to ensure proper conversion from string values toDecimalobjects. This includes tests for basic integers, basic decimals, negative numbers, zero variants, scientific notation, formatting variants, special characters, invalid inputs, boundary cases, and special cases.Updates to
mojoproject.toml:test_from_floatandtest_from_stringto thetestsection.bench_from_floatandbench_from_stringto thebenchsection.