public static int stringToInt(String s, int radix) throws IllegalArgumentException {
		
		/*
		 * (1) Determine if number should be negative (and starting index for
		 * processing the rest of the String.
		 */
		
		boolean isNegative = false;
		if (s.length() > 1 && s.charAt(0) == '-') {
			isNegative = true;		
		}
		
		int x = 0;
		
		for (int i = (isNegative? 1:0); i < s.length(); i++) {
						
			Character c = s.charAt(i);
			int t;
			if (Character.isDigit(c)) {
				t = Integer.valueOf(c) - '0';					
			}else {
				t = Integer.valueOf(c) - 'A' + 10;
			}

			if (t >= radix) {
				throw new IllegalArgumentException();
			}
			
			x = x * radix  +  t;
		
		}
		
		if (isNegative) {
			x = -x;
		}
		
		return x;
	}