Skip to content

Commit

Permalink
fixed files form Lang #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 4c30a74 commit 253a661
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions projects/Lang/1/org/apache/commons/lang3/math/NumberUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,20 @@ public static Number createNumber(final String str) throws NumberFormatException
}
}
if (pfxLen > 0) { // we have a hex number
char firstSigDigit = 0; // strip leading zeroes
for(int i = pfxLen; i < str.length(); i++) {
firstSigDigit = str.charAt(i);
if (firstSigDigit == '0') { // count leading zeroes
pfxLen++;
} else {
break;
}
}
final int hexDigits = str.length() - pfxLen;
if (hexDigits > 16) { // too many for Long
if (hexDigits > 16 || (hexDigits == 16 && firstSigDigit > '7')) { // too many for Long
return createBigInteger(str);
}
if (hexDigits > 8) { // too many for an int
if (hexDigits > 8 || (hexDigits == 8 && firstSigDigit > '7')) { // too many for an int
return createLong(str);
}
return createInteger(str);
Expand Down

0 comments on commit 253a661

Please sign in to comment.