[decimal] Implement sqrt for BigDecimal
#73
Merged
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 introduces several enhancements to the
BigDecimaltype in the DeciMojo library, including the addition of square root functionality and related tests. The most important changes include updates to theBigDecimalstruct, new exponential functions, and corresponding unit tests.Enhancements to
BigDecimaltype:src/decimojo/bigdecimal/bigdecimal.mojo: Addedsqrtmethod to compute the square root of aBigDecimalnumber with a specified precision, and anis_negativemethod to check if a number is negative. [1] [2]New exponential functions:
src/decimojo/bigdecimal/exponential.mojo: Implemented thesqrtfunction to calculate the square root of aBigDecimalnumber, handling special cases and performing Newton's method iterations for precision.Unit tests for exponential functions:
tests/bigdecimal/test_bigdecimal_exponential.mojo: Added tests for thesqrtfunction, including cases for perfect squares, non-perfect squares, decimal inputs, large numbers, small numbers, scientific notation, and precision tests.tests/bigdecimal/test_data/bigdecimal_exponential.toml: Created test data for the square root tests, covering a variety of input scenarios.Other updates:
README.md: Updated the core types table to include aliases forBigUInt,BigInt,Decimal, andBigDecimal.benches/bigdecimal/bench.mojo: Added benchmarking support for the square root operation. [1] [2] [3]