mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 09:24:42 -04:00
improved the number parser
This commit is contained in:
parent
2c311f6e70
commit
02e700f463
@ -158,31 +158,32 @@ public final class Bits {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int radix;
|
int radix;
|
||||||
switch (str.charAt(p)) {
|
if (wasZero) {
|
||||||
case 'x':
|
if (neg) throw new NumberFormatException(str, p);
|
||||||
case 'X':
|
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);
|
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++;
|
p++;
|
||||||
if (p == str.length()) throw new NumberFormatException(str, p);
|
if (p == str.length()) throw new NumberFormatException(str, p);
|
||||||
return str.charAt(p);
|
return str.charAt(p);
|
||||||
default:
|
} else
|
||||||
if (wasZero) {
|
radix = 10;
|
||||||
if (neg) throw new NumberFormatException(str, p);
|
|
||||||
radix = 8;
|
|
||||||
} else
|
|
||||||
radix = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long val = decode(str, p, radix);
|
long val = decode(str, p, radix);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user