Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/java/org/apache/commons/lang3/math/NumberUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,15 @@ private static boolean isParsableDecimal(final String str, final int beginIdx) {
// See https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-NonZeroDigit
int decimalPoints = 0;
boolean asciiNumeric = true;
final int lastIndex = str.length() - 1;

for (int i = beginIdx; i < str.length(); i++) {
final char ch = str.charAt(i);

if(i == lastIndex && (ch == 'f' || ch == 'F' || ch == 'd' || ch == 'D')){
return true;
}

final boolean isDecimalPoint = ch == '.';
if (isDecimalPoint) {
decimalPoints++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,8 @@ void testIsParsable() {
assertTrue(NumberUtils.isParsable("-018.2"));
assertTrue(NumberUtils.isParsable("-.236"));
assertTrue(NumberUtils.isParsable("2."));
// TODO assertTrue(NumberUtils.isParsable("2.f"));
// TODO assertTrue(NumberUtils.isParsable("2.d"));
assertTrue(NumberUtils.isParsable("2.f"));
assertTrue(NumberUtils.isParsable("2.d"));
}

/**
Expand Down