Skip to content

fix(display): correct negative BigInt rendering in fmtTokenAmount and formatBigInt - #68

Open
Sertug17 wants to merge 1 commit into
base:mainfrom
Sertug17:fix/negative-bigint-token-display
Open

fix(display): correct negative BigInt rendering in fmtTokenAmount and formatBigInt#68
Sertug17 wants to merge 1 commit into
base:mainfrom
Sertug17:fix/negative-bigint-token-display

Conversation

@Sertug17

Copy link
Copy Markdown

Summary

Fixes negative token amounts displaying as "-1.-5 ETH" instead of "-1.5 ETH".

Root cause

JavaScript's BigInt % operator preserves the sign of the dividend. For negative value, the fractional part was also negative, producing a - prefix in the fraction string that got concatenated into the output.

Fix

Use absolute value for all fractional arithmetic and prepend the sign explicitly.

Affected files

  • app/vibenet/library/explorer.ts fmtTokenAmount
  • app/tips/library/format.ts formatBigInt

Testing

fmtTokenAmount(-1_500_000_000_000_000_000n, 18) // was: "-1.-5", now: "-1.5"
fmtTokenAmount(-500_000_000_000_000_000n, 18)   // was: "0.-5",  now: "-0.5"

Closes #66

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

@Sertug17 is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@Sertug17

Copy link
Copy Markdown
Author

Hey @montycheese @haardikk21 small display bug fix here, would appreciate a review when you get a chance. Happy to adjust if anything looks off.

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.

fix(display): negative token amounts render as "-1.-5 ETH" due to BigInt modulo sign propagation

2 participants