From 253a66182b08c9e1b9b2dc9ca6536d6f3f8a71d2 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:25:32 +0100 Subject: [PATCH] fixed files form Lang #1 --- .../org/apache/commons/lang3/math/NumberUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/projects/Lang/1/org/apache/commons/lang3/math/NumberUtils.java b/projects/Lang/1/org/apache/commons/lang3/math/NumberUtils.java index 1e6ccdc..70b8d64 100644 --- a/projects/Lang/1/org/apache/commons/lang3/math/NumberUtils.java +++ b/projects/Lang/1/org/apache/commons/lang3/math/NumberUtils.java @@ -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);