4d6a2c
--- bc-1.06/dc/numeric.c.dc_ibase	2007-08-22 08:37:57.000000000 +0200
4d6a2c
+++ bc-1.06/dc/numeric.c	2007-08-22 08:37:40.000000000 +0200
4d6a2c
@@ -285,6 +285,8 @@ dc_getnum DC_DECLARG((input, ibase, read
4d6a2c
 	int		digit;
4d6a2c
 	int		decimal;
4d6a2c
 	int		c;
4d6a2c
+	int		c_buff = 0;
4d6a2c
+	int		multi = 0;
4d6a2c
 
4d6a2c
 	bc_init_num(&tmp);
4d6a2c
 	bc_init_num(&build);
4d6a2c
@@ -302,6 +304,9 @@ dc_getnum DC_DECLARG((input, ibase, read
4d6a2c
 	}
4d6a2c
 	while (isspace(c))
4d6a2c
 		c = (*input)();
4d6a2c
+	c_buff = (*input)();	
4d6a2c
+	if (isdigit(c_buff) || ('A' <= c_buff && c_buff <= 'F') || c_buff == '.')
4d6a2c
+			multi = 1;		
4d6a2c
 	for (;;){
4d6a2c
 		if (isdigit(c))
4d6a2c
 			digit = c - '0';
4d6a2c
@@ -309,10 +314,15 @@ dc_getnum DC_DECLARG((input, ibase, read
4d6a2c
 			digit = 10 + c - 'A';
4d6a2c
 		else
4d6a2c
 			break;
4d6a2c
-		c = (*input)();
4d6a2c
+		digit = multi ? (digit >= ibase ? ibase -1 : digit) : digit;
4d6a2c
 		bc_int2num(&tmp, digit);
4d6a2c
 		bc_multiply(result, base, &result, 0);
4d6a2c
 		bc_add(result, tmp, &result, 0);
4d6a2c
+		if (c_buff) {
4d6a2c
+			c = c_buff;
4d6a2c
+			c_buff = 0;
4d6a2c
+		} else
4d6a2c
+			c = (*input)();
4d6a2c
 	}
4d6a2c
 	if (c == '.'){
4d6a2c
 		bc_free_num(&build);
4d6a2c
@@ -321,13 +331,18 @@ dc_getnum DC_DECLARG((input, ibase, read
4d6a2c
 		build = bc_copy_num(_zero_);
4d6a2c
 		decimal = 0;
4d6a2c
 		for (;;){
4d6a2c
-			c = (*input)();
4d6a2c
+			if (c_buff) {
4d6a2c
+				c = c_buff;
4d6a2c
+				c_buff = 0;
4d6a2c
+			} else
4d6a2c
+				c = (*input)();
4d6a2c
 			if (isdigit(c))
4d6a2c
 				digit = c - '0';
4d6a2c
 			else if ('A' <= c && c <= 'F')
4d6a2c
 				digit = 10 + c - 'A';
4d6a2c
 			else
4d6a2c
 				break;
4d6a2c
+			digit = digit >= ibase ? ibase -1 : digit;
4d6a2c
 			bc_int2num(&tmp, digit);
4d6a2c
 			bc_multiply(build, base, &build, 0);
4d6a2c
 			bc_add(build, tmp, &build, 0);