Skip to content

[LANG-1806] NumberUtils.isParsable("1.f") should return true#1560

Merged
garydgregory merged 17 commits intoapache:masterfrom
garydgregory:bugfix/LANG-1806_NumberUtils_isParsable
Jan 11, 2026
Merged

[LANG-1806] NumberUtils.isParsable("1.f") should return true#1560
garydgregory merged 17 commits intoapache:masterfrom
garydgregory:bugfix/LANG-1806_NumberUtils_isParsable

Conversation

@garydgregory
Copy link
Copy Markdown
Member

@garydgregory garydgregory commented Jan 10, 2026

[LANG-1806] NumberUtils.isParsable("1.f") should return true

  • Return true for numbers like 1.2e-5d and 1.2e-5f
  • Use a regular expression

Before you push a pull request, review this list:

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request: Claude Sonet 4.5
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory garydgregory changed the title [LANG-1806] number utils is parsable [LANG-1806] NumberUtils.isParsable("1.f") should return true Jan 10, 2026
- Return true for numbers like 1.2e-5d and 1.2e-5f
- Return true when one of the following would work:
-- Double.parseDouble(String)
-- Float.parseFloat(String)
-- Long.parseLong(String)
-- Integer.parseInteger(String)

There are so many cases that it's simpler to try to parse and catch
exceptions, instead of re-creating all the parsing rules from the JRE.
The only downside is that number instances are created and discarded.
@garydgregory garydgregory force-pushed the bugfix/LANG-1806_NumberUtils_isParsable branch from 670badc to 06a6b1f Compare January 11, 2026 22:01
@garydgregory garydgregory merged commit 8089a0c into apache:master Jan 11, 2026
20 checks passed
@garydgregory garydgregory deleted the bugfix/LANG-1806_NumberUtils_isParsable branch January 11, 2026 22:29
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