Skip to content

[dec128] to_string consolidation + New utility methods#240

Merged
forfudan merged 3 commits intomainfrom
dev
May 5, 2026
Merged

[dec128] to_string consolidation + New utility methods#240
forfudan merged 3 commits intomainfrom
dev

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented May 4, 2026

This PR expands Decimal128’s formatting and introspection surface by consolidating scientific formatting into to_string(...), adding engineering notation and digit-group separator support, and introducing several small utility/dunder methods consistent with the existing BigDecimal API shape.

Changes:

  • Consolidate to_string_scientific() into Decimal128.to_string(scientific=..., engineering=..., delimiter=...), adding engineering notation and mantissa digit grouping.
  • Add __bool__, __pos__, is_positive(), is_odd(), number_of_trailing_zeros(), plus to_scientific_string() / to_eng_string() / to_string_with_separators() aliases.
  • Add comprehensive tests for the new formatting paths and utility methods; update docs/changelog to describe the API changes.

Co-authored-by: Copilot <copilot@github.com>
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 expands Decimal128’s formatting and introspection surface by consolidating scientific formatting into to_string(...), adding engineering notation and digit-group separator support, and introducing several small utility/dunder methods consistent with the existing BigDecimal API shape.

Changes:

  • Consolidate to_string_scientific() into Decimal128.to_string(scientific=..., engineering=..., delimiter=...), adding engineering notation and mantissa digit grouping.
  • Add __bool__, __pos__, is_positive(), is_odd(), number_of_trailing_zeros(), plus to_scientific_string() / to_eng_string() / to_string_with_separators() aliases.
  • Add comprehensive tests for the new formatting paths and utility methods; update docs/changelog to describe the API changes.

Reviewed changes

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

File Description
src/decimo/decimal128/decimal128.mojo Implements consolidated to_string(...), engineering formatting, digit separator insertion helper, and new utility/dunder methods; removes some prior APIs.
tests/decimal128/test_decimal128_methods.mojo Adds tests covering scientific/engineering formatting, delimiter grouping, __bool__, __pos__, and new utility methods.
docs/changelog.md Documents the new APIs and the to_string consolidation/removals.
docs/plans/decimal128_enhancement.md Updates the Decimal128 audit plan notes and adds an “API additions” section + updated priority summary.

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

Comment thread src/decimo/decimal128/decimal128.mojo Outdated
Comment thread src/decimo/decimal128/decimal128.mojo
forfudan and others added 2 commits May 5, 2026 00:31
Co-authored-by: Copilot <copilot@github.com>
@forfudan forfudan merged commit eb29500 into main May 5, 2026
11 checks passed
@forfudan forfudan deleted the dev branch May 5, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants