Skip to content

[decimal] Change exponent() to adjusted() + copy_abs() + copy_negate() + copy_sign()#176

Merged
forfudan merged 2 commits intoclifrom
update
Feb 28, 2026
Merged

[decimal] Change exponent() to adjusted() + copy_abs() + copy_negate() + copy_sign()#176
forfudan merged 2 commits intoclifrom
update

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Feb 28, 2026

Related to Issue #175 .

This PR aligns BigDecimal’s API more closely with Python’s decimal.Decimal by renaming the scientific-notation exponent helper to adjusted() and adding sign-copying convenience methods, then updates internal call sites and documentation/tests accordingly.

Changes:

  • Rename BigDecimal.exponent() to BigDecimal.adjusted() and update call sites in exponential math routines. Note that 0.00 now returns 0 rather than 2.
  • Add copy_abs(), copy_negate(), and copy_sign() to BigDecimal.
  • Add/extend tests and update the API roadmap to reflect the new/renamed methods.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns BigDecimal’s API more closely with Python’s decimal.Decimal by renaming the scientific-notation exponent helper to adjusted() and adding sign-copying convenience methods, then updates internal call sites and documentation/tests accordingly.

Changes:

  • Rename BigDecimal.exponent() to BigDecimal.adjusted() and update call sites in exponential math routines.
  • Add copy_abs(), copy_negate(), and copy_sign() to BigDecimal.
  • Add/extend tests and update the API roadmap to reflect the new/renamed methods.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tests/bigdecimal/test_bigdecimal_methods.mojo Adds tests for copy_* methods and adjusted().
src/decimo/bigdecimal/exponential.mojo Replaces exponent() usages with adjusted() in exp/ln/sqrt-related logic.
src/decimo/bigdecimal/bigdecimal.mojo Implements adjusted() and introduces copy_abs/copy_negate/copy_sign.
docs/plans/api_roadmap.md Marks adjusted() and copy_* methods as done.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@forfudan forfudan added the enhancement New feature or request label Feb 28, 2026
@forfudan forfudan merged commit 4d8672e into cli Feb 28, 2026
1 check passed
@forfudan forfudan deleted the update branch February 28, 2026 15:44
forfudan added a commit that referenced this pull request Mar 23, 2026
…negate()` + `copy_sign()` (#176)

Related to Issue #175 .

This PR aligns `BigDecimal`’s API more closely with Python’s
`decimal.Decimal` by renaming the scientific-notation exponent helper to
`adjusted()` and adding sign-copying convenience methods, then updates
internal call sites and documentation/tests accordingly.

**Changes:**
- Rename `BigDecimal.exponent()` to `BigDecimal.adjusted()` and update
call sites in exponential math routines. Note that `0.00` now returns 0
rather than 2.
- Add `copy_abs()`, `copy_negate()`, and `copy_sign()` to `BigDecimal`.
- Add/extend tests and update the API roadmap to reflect the new/renamed
methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants