Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix floating point issue in convertToMinorUnit [ROW-512] #194

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

RgnDunes
Copy link
Collaborator

Description

https://razorpay.slack.com/archives/C05JJL46C93/p1734083710224829?thread_ts=1733977437.431299&cid=C05JJL46C93

Root Cause:
The issue arises from JavaScript’s floating-point arithmetic using IEEE 754, which cannot accurately represent some decimal values. This causes precision errors, such as 4.14 * 100 resulting in 413.99999999999994 instead of 414.

Changes Made

List the main changes made in this pull request.

Title ---
JIRA link https://razorpay.atlassian.net/browse/ROW-512
Slack thread (if any) https://razorpay.slack.com/archives/C05JJL46C93/p1734083710224829?thread_ts=1733977437.431299&cid=C05JJL46C93
Product spec NA
Tech spec/One-pager NA
Bundle Size Difference NA
Fixes Issue NA

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change is a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Is your change backward compatible ?
  • Tested on major browsers (Chrome, Firefox, Safari, IE) ?
  • Tested in a consumer application(s) ?

Additional Notes

Any additional information that would be helpful for the reviewer.

Checklist:

  • Add Jira ID(s) in PR title and in the description?
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My code is written in TypeScript and follows the coding standards of the project.
  • [NA] I have added relevant documentation and updated the README if necessary.
  • My commit messages are clear and follow the project's commit message conventions.
  • Is any external library added?
  • My changes do not introduce any new runtime errors or warnings.
  • All relevant unit tests have been added/updated in my PR for the change.
  • [NA] Any Screenshots (mobile & desktop) required for PR? If yes, have you added the respective screenshots ?
  • Any manual dev testing done by you on beta/func environment?
  • Reviewer added (SLA 2 days)

Reviewer Checklist

  • Sufficient QA/Dev-Testing is done with proof (test cases list)
  • Ensure that the change in bundle size falls within the acceptable range.

PR Title Format

Format: <type>: <subject>

Types can be as follows:

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Copy link

changeset-bot bot commented Dec 16, 2024

🦋 Changeset detected

Latest commit: bdbf9dd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/i18nify-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment has been minimized.

@codecov-commenter
Copy link

codecov-commenter commented Dec 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.59%. Comparing base (03b688c) to head (bdbf9dd).
Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #194   +/-   ##
=======================================
  Coverage   96.59%   96.59%           
=======================================
  Files          51       51           
  Lines         704      704           
  Branches      172      173    +1     
=======================================
  Hits          680      680           
  Misses         24       24           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This comment has been minimized.

This comment has been minimized.

@rzpcibot
Copy link
Contributor

rzpcibot commented Dec 16, 2024

Bundle Size Report

Files

click to expand/collapse
🟢 No Change 🗑 File Deleted 🆕 New File 📈 Size Increased 👍 Size Reduced
Parsed (kb)
🚦 File Name Base PR Diff %
📈 cjs/index.js 158.28 158.3 $\textcolor{red}{0.02}$ 0.01
📈 esm/index.min.js 60.27 60.3 $\textcolor{red}{0.03}$ 0.05
📈 umd/index.js 179.56 179.58 $\textcolor{red}{0.02}$ 0.01

Generated by 🚫 dangerJS against bdbf9dd

This comment has been minimized.

@RgnDunes RgnDunes merged commit 5bbace7 into master Dec 16, 2024
16 checks passed
@RgnDunes RgnDunes deleted the fix/floating-point branch December 16, 2024 17:30
Copy link
Contributor

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0 ❌

Results for commit 5bbace7.

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.

4 participants