Index: calctool.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.c,v
retrieving revision 1.111
diff -u -r1.111 calctool.c
--- calctool.c	22 Sep 2006 15:22:19 -0000	1.111
+++ calctool.c	26 Sep 2006 20:15:23 -0000
@@ -52,7 +52,7 @@
     "accuracy", "base", "display", "modetype", "showregisters", "trigtype",
     "showzeroes", "showthousands", "syntax", "xposition", "yposition",
     "register0", "register1", "register2", "register3", "register4",
-    "register5", "register6", "register7", "register8", "register9"
+    "register5", "register6", "register7", "register8", "register9", "bitcalculating"
 };
 
 char *dtype_str[] = {          /* Strings for each display mode value. */
Index: gtk.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gtk.c,v
retrieving revision 1.203
diff -u -r1.203 gtk.c
--- gtk.c	22 Sep 2006 15:22:20 -0000	1.203
+++ gtk.c	26 Sep 2006 20:15:28 -0000
@@ -3028,6 +3028,50 @@
     }
 }
 
+void
+bin_str(int MP_value[MP_SIZE], 
+		char *str, 
+		int maxbits)
+{
+  
+  int MP0[MP_SIZE];
+  int MP1[MP_SIZE];
+  int MP2[MP_SIZE];
+  int MP3[MP_SIZE];
+  int i;
+
+  int neg = 0;
+
+  MPstr_to_num("0", DEC, MP0);
+  MPstr_to_num("1", DEC, MP1);
+  MPstr_to_num("2", DEC, MP2);
+
+  if (mplt(MP_value, MP0)) {
+	mpcmim(MP_value, MP0);
+	mpadd(MP0, MP1, MP0);
+	neg = 1;
+  } else {
+	mpcmim(MP_value, MP0);
+  }
+ 
+  for (i = 0; i < maxbits; i++) {
+
+	double lsb; // least significant bit 
+	calc_and(MP3, MP0, MP1);
+	mpcmd(MP3, &lsb);
+
+	if (lsb == 0) {
+	  str[maxbits - i -1] = (neg) ? '1' : '0';
+	} else {
+	  str[maxbits - i -1] = (neg) ? '0' : '1';
+	} 
+
+	mpdiv(MP0, MP2, MP3);
+	mpcmim(MP3, MP0);
+  }
+
+  return;
+}
 
 void
 set_bit_panel() {
@@ -3064,25 +3108,21 @@
 	case exprs:
 	  {
 		int MP[MP_SIZE];
-		int bit_str_len, i;
-		char *bit_str, label[3], tmp[MAXLINE];
+		int i;
+		char str[64], label[3];
 		int ret = usable_num(MP);
 
 		if (ret || !is_integer(MP)) {
 		  gtk_widget_set_sensitive(X->bit_panel, FALSE);
 		  return;
 		}
+		bin_str(MP, str, 64);
+		gtk_widget_set_sensitive(X->bit_panel, TRUE);
 		
-		bit_str = make_fixed(MP, tmp, BIN, MAXLINE, FALSE);
-		bit_str_len = strlen(bit_str);
-		if (bit_str_len <= MAXBITS) {
-		  gtk_widget_set_sensitive(X->bit_panel, TRUE);
-		  
-		  STRCPY(label, " 0");
-		  for (i = 0; i < MAXBITS; i++) {
-			label[1] = (i < bit_str_len) ? bit_str[bit_str_len-i-1] : '0';
-			gtk_label_set_text(GTK_LABEL(X->bits[MAXBITS - i - 1]), label);
-		  }
+		STRCPY(label, " 0");
+		for (i = 0; i < 64; i++) {
+		  label[1] = str[64 - i - 1];
+		  gtk_label_set_text(GTK_LABEL(X->bits[64 - i - 1]), label);
 		}
 	  }
 	  break;
