Skip to content

fix(maths): correct decimal isolation regex and add boundary tests (R50-T032) - #70

Open
nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T032
Open

nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T032

Conversation

@nishadaniket174

@nishadaniket174 nishadaniket174 commented Nov 13, 2026 •

Copy link
Copy Markdown

Description

This PR fixes an issue in the decimalIsolate() function in Maths/DecimalIsolate.js.

The original regular expression did not correctly identify the decimal point, which caused incorrect results for certain inputs, particularly single-digit integers.

The implementation has been updated to correctly isolate the fractional part of a number and return 0 when there is no decimal part or when the number is outside the supported format.

What has changed?

  • Fixed the regular expression to match the decimal point correctly.

  • Added a check to handle numbers without a decimal point.

  • Improved the function documentation to explain its supported input range and expected behavior.

  • Added tests covering normal inputs, boundary values, negative numbers, integers, and unsupported exponential notation.

Test cases covered

Input | Expected result -- | -- 12.34 | 0.34 -1.2 | 0.2 0.5 | 0.5 0.000001 | 0.000001 -0.000001 | 0.000001 1.000001 | 0.000001 0, 1, 10 | 0 1e-7, 1e21 | 0

Testing and verification

  • Initially reproduced the bug with a failing test for input 1.

  • All 11 focused tests passed after the fix.

  • Full repository test suite passed: 11,981 tests.

  • Prettier formatting and npm run check-style passed.

Files changed

  • Maths/DecimalIsolate.js

  • Maths/test/DecimalIsolate.test.js

  • work/R50-T032/WORK_LOG.md

  • work/R50-T032/check.py

Task: R50-T032

This change fixes the incorrect decimal extraction behavior and adds tests to help prevent the same issue from returning in the future.

@nishadaniket174 nishadaniket174 changed the title fix(maths): correct decimal isolation regex and add boundary tests fix(maths): correct decimal isolation regex and add boundary tests (R50-T032) Nov 21, 2026
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.

1 participant