Skip to content

fix: roundToCents uses Math.round instead of Math.floor to round to n… - #1453

Closed
jotel-dev wants to merge 1 commit into
LabsCrypt:mainfrom
jotel-dev:1372-backend-fix-rounding-down
Closed

fix: roundToCents uses Math.round instead of Math.floor to round to n…#1453
jotel-dev wants to merge 1 commit into
LabsCrypt:mainfrom
jotel-dev:1372-backend-fix-rounding-down

Conversation

@jotel-dev

@jotel-dev jotel-dev commented Jul 27, 2026

Copy link
Copy Markdown

No description provided.

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right diagnosis, Math.floor always rounding down is a real bug. but the repo money policy (backend/src/money/policy.generated.ts) specifies half_even rounding, and Math.round is half-up (and asymmetric for negatives), so this fix trades one policy violation for another. the money-policy CI job only checks artifact drift, which is why it stays green.

  1. round via the half-even helper in backend/src/money/decimal.ts (or equivalent) instead of Math.round.
  2. add a unit test covering the .5 cases (e.g. 0.125 -> 0.12 and 0.135 -> 0.14).

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@jotel-dev jotel-dev closed this Aug 8, 2026
@jotel-dev
jotel-dev deleted the 1372-backend-fix-rounding-down branch August 8, 2026 11:17
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.

2 participants