Skip to content

fix: document parseFloat precision limits on balanceFloat (#246) - #327

Merged
k-deejah merged 2 commits into
Sorokit:mainfrom
Buchi-Einstein:feat/246-getaccount-parsefloat-precision
Jul 28, 2026
Merged

fix: document parseFloat precision limits on balanceFloat (#246)#327
k-deejah merged 2 commits into
Sorokit:mainfrom
Buchi-Einstein:feat/246-getaccount-parsefloat-precision

Conversation

@Buchi-Einstein

Copy link
Copy Markdown
Contributor

Summary

Documents the precision limitation of parseFloat on Stellar balance strings and adds a test verifying the safe boundary.

Changes

  • src/account/types.ts — Added JSDoc on AssetBalance.balanceFloat warning about IEEE-754 double precision limits (~9e15 integer, ~900B XLM with 7 decimals)
  • src/account/getAccount.ts — Added explanatory comment and extracted pf helper before parseFloat calls
  • src/tests/account.test.ts — Added parseFloat precision boundary test 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 that parseFloat can safely represent. Any balance under 100 billion XLM (far beyond any real account) is guaranteed lossless.

Closes #246

- 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
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@k-deejah
k-deejah merged commit 1d314ab into Sorokit:main Jul 28, 2026
1 of 5 checks passed
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.

getAccount Uses parseFloat on Balance Strings — Loses Precision for Large Balances

2 participants