fix: document parseFloat precision limits on balanceFloat (#246) - #327
Merged
k-deejah merged 2 commits intoJul 28, 2026
Merged
Conversation
- Add JSDoc warning on AssetBalance.balanceFloat in types.ts - Add comments in getAccount.ts explaining precision boundary - Add test documenting the maximum safe float balance value (~900B XLM) - Demonstrate where precision loss begins for quadrillion-scale balances Closes Sorokit#246
|
@Buchi-Einstein Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Documents the precision limitation of
parseFloaton Stellar balance strings and adds a test verifying the safe boundary.Changes
src/account/types.ts— Added JSDoc onAssetBalance.balanceFloatwarning about IEEE-754 double precision limits (~9e15 integer, ~900B XLM with 7 decimals)src/account/getAccount.ts— Added explanatory comment and extractedpfhelper beforeparseFloatcallssrc/tests/account.test.ts— AddedparseFloat precision boundarytest proving that all realistic balances under 100B XLM round-trip safely, and demonstrating where precision loss begins (~1 quadrillion XLM)Precision boundary
Number.MAX_SAFE_INTEGER / 10^7 ≈ 900,719,925,474 XLM— the largest Stellar balance thatparseFloatcan safely represent. Any balance under 100 billion XLM (far beyond any real account) is guaranteed lossless.Closes #246