Skip to content

LANG-1806: Allow floating-point suffixes in NumberUtils.isParsable#1546

Closed
Jagdish-Singh-Bisht wants to merge 3 commits intoapache:masterfrom
Jagdish-Singh-Bisht:LANG-1806-numberutils-suffix
Closed

LANG-1806: Allow floating-point suffixes in NumberUtils.isParsable#1546
Jagdish-Singh-Bisht wants to merge 3 commits intoapache:masterfrom
Jagdish-Singh-Bisht:LANG-1806-numberutils-suffix

Conversation

@Jagdish-Singh-Bisht
Copy link
Copy Markdown

This PR addresses LANG-1806 as a small follow-up to LANG-1695.

NumberUtils.isParsable currently rejects strings such as "1.f" and "1.d", even though Float.parseFloat("1.f") and Double.parseDouble(1.d") succeed.

The test suite already contained TODOs for these cases, this change uncomments those assertions and updates the parsing logic to allow floating-point suffixes (f/F/d/D) only when they appear as the final character.

The change is intentionally minimal and doesn not affect other numeric formats.

Copy link
Copy Markdown
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hello @Jagdish-Singh-Bisht

This PR doesn't handle:

  • 1.2e-5d
  • 1.2e-5f

You did not follow the instructions in the PR template:

  • Run mvn
  • Fix all errors
  • Also remove the extra blank lines.

Rebase on git master where I added test TODOs for the above.

@Jagdish-Singh-Bisht
Copy link
Copy Markdown
Author

Thanks for the review.

Understood regarding the scientific notation cases (1.2e-5d / 1.2e-5f).
I'll rebase on current master, address those cases, clean-up formatting, and confirm mvn test before updating the PR.

@Jagdish-Singh-Bisht Jagdish-Singh-Bisht force-pushed the LANG-1806-numberutils-suffix branch from 1ad007d to 5e48311 Compare January 3, 2026 03:39
@Jagdish-Singh-Bisht
Copy link
Copy Markdown
Author

Thanks for the review and guidance.

I have rebased on the latest master, cleaned up formatting, and verified the build with mvn test.

This PR intentionally limits the scope to suffix-only cases(2.f, 2.d) as a minimal follow-up to LANG-1695.
The cases (1.2e-5f, 1.2e-5d) remain as TODOs added on master, since they would require additional exponent-parsing logic
and may be better addressed separately.

Please let me know if you'd prefer those cases to be handled in this PR.

@garydgregory
Copy link
Copy Markdown
Member

@Jagdish-Singh-Bisht
Still -1: I have the same comment as before: We don't need to have a special case for this one kind of float since we know it doesn't work for numbers like 1.2e-5d and 1.2e-5f. Fix it all here please.

@Jagdish-Singh-Bisht
Copy link
Copy Markdown
Author

I have pushed the updated implementation that fully supports scientific notation with float/double suffixes.
Please let me know if anything else is needed.

Copy link
Copy Markdown
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hello @Jagdish-Singh-Bisht

Thank you for updating your PR. Unfortunately, you did not follow the instructions in the PR template. You must run mvn by itself to validate your changes, which in this case, will fail the Checkstyle portion of the build.

I was thinking of something simpler, using a regular expression: Please test #1560 for your use case and me know if that works in your application.

@garydgregory
Copy link
Copy Markdown
Member

Closing: No reply. Implemented in git master with #1560

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