Skip to content

feat(data): add fixed-precision decimal arithmetic - #642

Merged
TheVicky1 merged 1 commit into
TheVicky1:mainfrom
SibiSudhanElangovan:feat/data-fixed-decimal
Oct 21, 2026
Merged

TheVicky1 merged 1 commit into
TheVicky1:mainfrom
SibiSudhanElangovan:feat/data-fixed-decimal

Conversation

@SibiSudhanElangovan

Copy link
Copy Markdown
Contributor

1. Related Issue

Closes #619

2. Summary of Changes

  • Added src/lib/data/fixed-decimal.ts with fixed-precision decimal arithmetic helpers.
  • Implemented addition (addFixed), subtraction (subFixed), multiplication (mulFixed), and division (divFixed).
  • Added rounding modes: half-even, half-up, and truncate.
  • Implemented roundFixed for rounding decimal values to a specified precision.
  • Implemented formatFixed with configurable decimal precision, thousands separators, and an optional currency prefix.
  • Added tests/fixed-decimal.test.ts to cover arithmetic operations, rounding behavior, formatting, exponent notation, and invalid inputs.

5. Testing & Local Validation

  • TypeScript check: npm run typecheck — passed.
  • Targeted tests: npm test -- fixed-decimal — passed.
  • Full test suite — passed.
  • npm run lint — not verified.
  • node scratch/secret-scan.mjs — not verified.
  • npm run build — not verified.

9. Contributor Quality Checklist

  • My PR has a single, focused scope.
  • My commits follow the Conventional Commits format.
  • I have linked the target issue in Section 1 above.
  • I reviewed my changes to ensure unrelated files were not included.
  • No secrets, API keys, private tokens, or .env.local files were intentionally included in this contribution.

@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@SibiSudhanElangovan is attempting to deploy a commit to the Vicky's projects Team on Vercel.

A member of the Team first needs to authorize it.

@TheVicky1
TheVicky1 merged commit eec9fae into TheVicky1:main Oct 21, 2026
3 of 4 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.

[Data] Add Fixed-Precision Currency & Percentage Decimal Arithmetic Helper in src/lib/data/fixed-decimal.ts

2 participants