// Converts from any number system < 17 to decimal.
int convertToDecimal(string x /* number to convert */, 
			int b /* base - must be < 17 & pos. */)
{
	int n = x.length();
	if (n == 0)
		return 0;
	else
	{
		char c = x[0];
		if (toupper(c) >= 'A' && toupper(c) <= 'F')
			return ((int(toupper(c)) - 55) * pow(b,n-1) 
				+ convertToDecimal(x.substr(1,n-1),b));
		else
			return ((int(c) - 48 ) * pow(b,n-1) 
				+ convertToDecimal(x.substr(1,n-1),b));
	}
}

