Add Intl.NumberFormat-based formatting helpers for fixed-points#1595
Merged
lorisleiva merged 1 commit intoMay 5, 2026
Merged
Conversation
This was referenced May 5, 2026
This was referenced May 5, 2026
Merged
Merged
Member
Author
BundleMonFiles updated (4)
Unchanged files (143)
Total files change +463B +0.09% Final result: ✅ View report in BundleMon website ➡️ |
Contributor
|
Documentation Preview: https://kit-docs-qpw4szr1i-anza-tech.vercel.app |
Member
Author
Merge activity
|
9b6b6b8 to
fe89315
Compare
e8a634b to
cbed45d
Compare
|
cbed45d to
45a8a82
Compare
fe89315 to
44f9dec
Compare
This PR adds three new public helpers to `@solana/fixed-points`: `formatDecimalFixedPoint` and `formatBinaryFixedPoint` accept any `Intl.NumberFormat` instance and route the underlying raw bigint through ES2023 string scientific notation (`"<raw>E-<decimals>"`), which preserves full precision regardless of the value's magnitude. They give consumers locale-aware output, currency formatting, grouping separators, and any rounding mode supported by `Intl.NumberFormat`, while the existing lossless `*ToString` helpers remain the recommended choice when portability across older runtimes (older Hermes/React Native, etc.) is a concern. The PR also exposes `binaryFixedPointToBase10`, which returns a binary fixed-point's exact `(raw, decimals)` base-10 representation. It is used internally by `formatBinaryFixedPoint` and by `binaryFixedPointToString` (deduplicating an inline conversion), and it lets consumers plug their own formatter on top of binary fixed-points just as they already can with decimal ones. Decimal fixed-points already expose `(raw, decimals)` directly on the value object so no equivalent helper is needed for them. Continuation of the discussion on #1567.
44f9dec to
3f490ac
Compare
Contributor
|
🔎💬 Inkeep AI search and chat service is syncing content for source 'Solana Kit Docs' |
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
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 PR adds three new public helpers to
@solana/fixed-points:formatDecimalFixedPointandformatBinaryFixedPointaccept anyIntl.NumberFormatinstance and route the underlying raw bigint through ES2023 string scientific notation ("<raw>E-<decimals>"), which preserves full precision regardless of the value's magnitude. They give consumers locale-aware output, currency formatting, grouping separators, and any rounding mode supported byIntl.NumberFormat, while the existing lossless*ToStringhelpers remain the recommended choice when portability across older runtimes (older Hermes/React Native, etc.) is a concern.The PR also exposes
binaryFixedPointToBase10, which returns a binary fixed-point's exact(raw, decimals)base-10 representation. It is used internally byformatBinaryFixedPointand bybinaryFixedPointToString(deduplicating an inline conversion), and it lets consumers plug their own formatter on top of binary fixed-points just as they already can with decimal ones. Decimal fixed-points already expose(raw, decimals)directly on the value object so no equivalent helper is needed for them.Continuation of the discussion on #1567.