improved the number parser

This commit is contained in:
hneemann 2018-02-26 12:28:28 +01:00
parent 2c311f6e70
commit 02e700f463

View File

@ -158,31 +158,32 @@ public final class Bits {
return 0;
int radix;
switch (str.charAt(p)) {
case 'x':
case 'X':
if (wasZero) {
if (neg) throw new NumberFormatException(str, p);
switch (str.charAt(p)) {
case 'x':
case 'X':
radix = 16;
p++;
if (p == str.length()) throw new NumberFormatException(str, p);
break;
case 'b':
case 'B':
radix = 2;
p++;
if (p == str.length()) throw new NumberFormatException(str, p);
break;
default:
radix = 8;
}
} else {
if (str.charAt(p) == '\'') {
if (neg) throw new NumberFormatException(str, p);
radix = 16;
p++;
if (p == str.length()) throw new NumberFormatException(str, p);
break;
case 'b':
case 'B':
if (neg) throw new NumberFormatException(str, p);
radix = 2;
p++;
if (p == str.length()) throw new NumberFormatException(str, p);
break;
case '\'':
p++;
if (p == str.length()) throw new NumberFormatException(str, p);
return str.charAt(p);
default:
if (wasZero) {
if (neg) throw new NumberFormatException(str, p);
radix = 8;
} else
radix = 10;
} else
radix = 10;
}
long val = decode(str, p, radix);