src/share/classes/java/math/BigInteger.java
Print this page
@@ -290,22 +290,22 @@
int cursor = 0, numDigits;
int len = val.length();
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
throw new NumberFormatException("Radix out of range");
- if (val.length() == 0)
+ if (len == 0)
throw new NumberFormatException("Zero length BigInteger");
// Check for at most one leading sign
int sign = 1;
int index1 = val.lastIndexOf('-');
int index2 = val.lastIndexOf('+');
if ((index1 + index2) <= -1) {
// No leading sign character or at most one leading sign character
if (index1 == 0 || index2 == 0) {
cursor = 1;
- if (val.length() == 1)
+ if (len == 1)
throw new NumberFormatException("Zero length BigInteger");
}
if (index1 == 0)
sign = -1;
} else
@@ -340,11 +340,11 @@
throw new NumberFormatException("Illegal digit");
// Process remaining digit groups
int superRadix = intRadix[radix];
int groupVal = 0;
- while (cursor < val.length()) {
+ while (cursor < len) {
group = val.substring(cursor, cursor += digitsPerInt[radix]);
groupVal = Integer.parseInt(group, radix);
if (groupVal < 0)
throw new NumberFormatException("Illegal digit");
destructiveMulAdd(magnitude, superRadix, groupVal);