[integer][decimal] Allows implicit type conversion and type merging #89
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 significant updates to
BigDecimal,BigInt, andBigUIntstructures in thedecimojolibrary. The changes add implicit constructors for better usability, refine initialization methods, and improve type handling for integral and floating-point scalars.Enhancements to
BigDecimal:src/decimojo/bigdecimal/bigdecimal.mojo: Added implicit constructors forBigUInt,BigInt,Int, and integral scalars, enabling seamless initialization ofBigDecimalobjects from these types.src/decimojo/bigdecimal/bigdecimal.mojo: Replaced thefrom_scalarmethod withfrom_integral_scalarand introducedfrom_floatfor better handling of integral and floating-point scalars. Improved constraints and error handling for scalar type validation. [1] [2]src/decimojo/bigdecimal/bigdecimal.mojo: Added right-side arithmetic dunders (__radd__,__rsub__, etc.) forBigDecimal, enabling more flexible cross-type operations.Enhancements to
BigInt:src/decimojo/bigint/bigint.mojo: Added implicit constructors forBigUInt,Int, and integral scalars, simplifying the initialization ofBigIntobjects. [1] [2]src/decimojo/bigint/bigint.mojo: Introducedfrom_integral_scalarfor handling integral scalars, replacingfrom_uint128with improved constraints and validation.Minor Refinements:
src/decimojo/bigdecimal/exponential.mojo: Updated thesqrtfunction to useBigUInt.from_unsigned_integral_scalar, ensuring consistent handling of unsigned integral scalars.src/decimojo/bigint/bigint.mojo: Marked certain initialization methods as unsafe and added warnings in their documentation to encourage users to use safer alternatives. [1] [2]These changes collectively improve the usability, readability, and robustness of the
decimojolibrary, making it more intuitive for developers working with arbitrary-precision arithmetic.