classpath progress

This commit is contained in:
Joel Dice
2007-07-27 17:56:19 -06:00
parent c9f9b039e6
commit 363801af1c
10 changed files with 211 additions and 24 deletions

View File

@ -32,4 +32,28 @@ public final class Long extends Number {
public double doubleValue() {
return (double) value;
}
private static long pow(long a, long b) {
long c = 1;
for (int i = 0; i < b; ++i) c *= a;
return c;
}
public static long parseLong(String s, int radix) {
long number = 0;
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (((c >= '0') && (c <= '9')) ||
((c >= 'a') && (c <= 'z'))) {
long digit = ((c >= '0' && c <= '9') ? (c - '0') : (c - 'a' + 10));
number += digit * pow(radix, (s.length() - i - 1));
} else {
throw new NumberFormatException("Invalid character " + c + " code " +
(int) c);
}
}
return number;
}
}