commons-lang icon indicating copy to clipboard operation
commons-lang copied to clipboard

LANG-1484: Allow decimal point at the end of the String

Open saksham93 opened this issue 5 years ago • 7 comments

LANG-1484: Allow decimal point at the end of the String because Double.parseDouble, Float.parseFloat allow this.

https://issues.apache.org/jira/projects/LANG/issues/LANG-1484

IMO, we can allow decimal at end of String. Please suggest.

saksham93 avatar Sep 09 '19 11:09 saksham93

Coverage Status

Coverage decreased (-0.0006%) to 95.215% when pulling 81bd39bdf430d256ef37d2bfa86f337d790b5aa5 on saksham93:LANG-1484-NumberUtils into ec92ddd1c605bce0700eace96fb84331ad06c1dd on apache:master.

coveralls avatar Sep 09 '19 11:09 coveralls

Maybe we should add a test to ensure the various parsing cases work ?

0x6e69636f avatar Sep 12 '19 14:09 0x6e69636f

@nicolasbd - NumberUtilsTest.java has test method for this. Do you have any suggestions to add more? I think it covers most of them. Please suggest

saksham93 avatar Sep 12 '19 15:09 saksham93

@saksham93 ah sorry I didn't know about those, but looking at them I see this : assertFalse( NumberUtils.isParsable("64.") ); for example I mean, maybe we should add some tests to ensure your modif is always okay, but I'm new to the project so it might not be necessary as you pointed out, maybe someone else will confirm

0x6e69636f avatar Sep 13 '19 07:09 0x6e69636f

@kinow - Hi, Can you please check if this PR looks good to you? Thank you.

saksham93 avatar Dec 26 '19 18:12 saksham93

Given that crap like -.236 or .18 are considered valid input, I see no reason why not more crap like 64. should not be allowed.

michael-o avatar Dec 26 '19 18:12 michael-o

Not a fan unless testIsParsable is updated to actually prove that something is parsable or not; for example, update:

        assertTrue( NumberUtils.isParsable("64") );

to

        assertTrue( NumberUtils.isParsable("64") );
        Integer.parseInt("64");

garydgregory avatar Feb 22 '20 13:02 garydgregory