gcalctool r2325 - in trunk: gcalctool po



Author: rancell
Date: Tue Dec  2 17:09:22 2008
New Revision: 2325
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2325&view=rev

Log:
Killed mpmath.[ch] and moved/renamed existing functions


Added:
   trunk/gcalctool/mp-boolean.c
Removed:
   trunk/gcalctool/mpmath.c
   trunk/gcalctool/mpmath.h
Modified:
   trunk/gcalctool/Makefile.am
   trunk/gcalctool/calctool.c
   trunk/gcalctool/calctool.h
   trunk/gcalctool/ce_parser.y
   trunk/gcalctool/ce_tokeniser.l
   trunk/gcalctool/display.c
   trunk/gcalctool/financial.c
   trunk/gcalctool/functions.c
   trunk/gcalctool/get.c
   trunk/gcalctool/gtk.c
   trunk/gcalctool/mp-convert.c
   trunk/gcalctool/mp.c
   trunk/gcalctool/mp.h
   trunk/gcalctool/register.c
   trunk/gcalctool/unittest.c
   trunk/po/POTFILES.in

Modified: trunk/gcalctool/Makefile.am
==============================================================================
--- trunk/gcalctool/Makefile.am	(original)
+++ trunk/gcalctool/Makefile.am	Tue Dec  2 17:09:22 2008
@@ -26,11 +26,10 @@
 	functions.h \
 	mp.c \
 	mp.h \
+	mp-boolean.c \
 	mp-convert.c \
 	mp-internal.h \
 	mp-trigonometric.c \
-	mpmath.c \
-	mpmath.h \
 	financial.c \
 	financial.h \
 	parser.c \

Modified: trunk/gcalctool/calctool.c
==============================================================================
--- trunk/gcalctool/calctool.c	(original)
+++ trunk/gcalctool/calctool.c	Tue Dec  2 17:09:22 2008
@@ -31,7 +31,7 @@
 #include "display.h"
 #include "functions.h"
 #include "ui.h"
-#include "mpmath.h"
+#include "mp.h"
 #include "register.h"
 
 time_t time();
@@ -41,9 +41,60 @@
 /* Calctool variables and options. */
 CalculatorVariables *v;
 
-/* Calctools' customised math library error-handling routine. */
+/* Change type to radian */
+void
+to_rad(int s1[MP_SIZE], int t1[MP_SIZE])
+{
+    int MP1[MP_SIZE], MP2[MP_SIZE];
+
+    if (v->ttype == DEG) {
+        mp_get_pi(MP1);
+        mpmul(s1, MP1, MP2);
+        mp_set_from_integer(180, MP1);
+        mpdiv(MP2, MP1, t1);
+    } else if (v->ttype == GRAD) {
+        mp_get_pi(MP1);
+        mpmul(s1, MP1, MP2);
+        mp_set_from_integer(200, MP1);
+        mpdiv(MP2, MP1, t1);
+    } else {
+        mp_set_from_mp(s1, t1);
+    }
+}
 
 void
+do_trig_typeconv(enum trig_type ttype, int s1[MP_SIZE], int t1[MP_SIZE])
+{
+    int MP1[MP_SIZE], MP2[MP_SIZE];
+  
+    switch (ttype) {
+
+        case DEG:
+            mp_set_from_integer(180, MP1);
+            mpmul(s1, MP1, MP2);
+            mp_get_pi(MP1);
+            mpdiv(MP2, MP1, t1);
+            break;
+
+        case RAD:
+            mp_set_from_mp(s1, t1);
+            break;
+
+        case GRAD:
+            mp_set_from_integer(200, MP1);
+            mpmul(s1, MP1, MP2);
+            mp_get_pi(MP1);
+            mpdiv(MP2, MP1, t1);
+            break;
+
+        default:
+            assert(0);
+            break;
+    }
+}
+
+/* Calctools' customised math library error-handling routine. */
+void
 doerr(char *errmes)
 {
     v->math_error = -MPMATH_ERR;

Modified: trunk/gcalctool/calctool.h
==============================================================================
--- trunk/gcalctool/calctool.h	(original)
+++ trunk/gcalctool/calctool.h	Tue Dec  2 17:09:22 2008
@@ -125,6 +125,11 @@
 extern CalculatorVariables *v; /* Calctool variables and options. */
 extern int basevals[];           /* Supported arithmetic bases. */
 
+/* Change type to radian */
+void to_rad(int s1[MP_SIZE], int t1[MP_SIZE]);
+
+void do_trig_typeconv(enum trig_type ttype, int s1[MP_SIZE], int t1[MP_SIZE]);
+
 void doerr(char *);
 
 #endif /*CALCTOOL_H*/

Modified: trunk/gcalctool/ce_parser.y
==============================================================================
--- trunk/gcalctool/ce_parser.y	(original)
+++ trunk/gcalctool/ce_parser.y	Tue Dec  2 17:09:22 2008
@@ -27,7 +27,6 @@
 #include "calctool.h"
 #include "register.h"
 #include "display.h"
-#include "mpmath.h"
 #include "parser.h"
 #include "parser_mac.h"
 #include "ce_parser.h"
@@ -144,38 +143,38 @@
 | exp '-' exp {mp_subtract($1, $3, $$);}
 
 | exp tMOD exp %prec MED {
-    if (!is_integer($1) || !is_integer($3)) {
+    if (!mp_is_integer($1) || !mp_is_integer($3)) {
 	parser_state.error = -PARSER_ERR_MODULUSOP;
     } else {
-      if (calc_modulus($1, $3, $$)) {
+      if (mp_modulus_divide($1, $3, $$)) {
         parser_state.error = -EINVAL;
       }			   
     }
 }
 
 | exp tAND exp {
-    if (!is_natural($1) || !is_natural($3)) {
+    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_and($1, $3, $$);
+    mp_and($1, $3, $$);
 }
 | exp tOR exp {
-    if (!is_natural($1) || !is_natural($3)) {
+    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_or($1, $3, $$);
+    mp_or($1, $3, $$);
 }
 | exp tXNOR exp {
-    if (!is_natural($1) || !is_natural($3)) {
+    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_xnor($1, $3, $$);
+    mp_xnor($1, $3, $$);
 }
 | exp tXOR exp {
-    if (!is_natural($1) || !is_natural($3)) {
+    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_xor($1, $3, $$);
+    mp_xor($1, $3, $$);
 }
 ;
 
@@ -185,18 +184,18 @@
 | rcl {cp($1, $$);}
 | term '/' term {mpdiv($1, $3, $$);}
 | term '*' term {mpmul($1, $3, $$);}
-| 'e' '^' term {calc_epowy($3, $$);} 
-| term '!' {calc_factorial($1 ,$$);}
-| term '%' {calc_percent($1, $$);}
+| 'e' '^' term {mp_epowy($3, $$);} 
+| term '!' {mp_factorial($1 ,$$);}
+| term '%' {mp_percent($1, $$);}
 | '~' term %prec LNEG {
-    if (!is_natural($2)) {
+    if (!mp_is_natural($2)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_not($2, $$);
+    mp_not($2, $$);
 }
 | '-' term %prec NEG {mp_invert_sign($2, $$);}
 | '+' term %prec POS {cp($2, $$);}
-| term '^' term {calc_xpowy($1, $3, $$);}
+| term '^' term {mp_xpowy($1, $3, $$);}
 
 | func {cp($1, $$);}
 | reg {cp($1, $$);}
@@ -213,31 +212,31 @@
   ;
 
 func:
-  tLOG10 term %prec HIGH {mplogn(10, $2, $$);}
-| tLOG2 term %prec HIGH {mplogn(2, $2, $$);}
+  tLOG10 term %prec HIGH {mp_logarithm(10, $2, $$);}
+| tLOG2 term %prec HIGH {mp_logarithm(2, $2, $$);}
 | tSQRT term %prec HIGH {mp_sqrt($2, $$);}
 | tLN term %prec HIGH {mpln($2, $$);}
-| tRAND %prec HIGH {calc_rand($$);}
+| tRAND %prec HIGH {mp_set_from_random($$);}
 | tABS term %prec HIGH {mp_abs($2, $$);}
 | tFRAC term %prec HIGH {mpcmf($2, $$);}
 | tINT term %prec HIGH {mpcmim($2, $$);}
 | tCHS term %prec HIGH {mp_invert_sign($2, $$);}
 
-| tSIN term %prec HIGH {calc_trigfunc(sin_t, $2, $$);}
-| tCOS term %prec HIGH {calc_trigfunc(cos_t, $2, $$);}
-| tTAN term %prec HIGH {calc_trigfunc(tan_t, $2, $$);}
-| tASIN term %prec HIGH {calc_trigfunc(asin_t, $2, $$);}
-| tACOS term %prec HIGH {calc_trigfunc(acos_t, $2, $$);}
-| tATAN term %prec HIGH {calc_trigfunc(atan_t, $2, $$);}
-| tSINH term %prec HIGH {calc_trigfunc(sinh_t, $2, $$);}
-| tCOSH term %prec HIGH {calc_trigfunc(cosh_t, $2, $$);}
-| tTANH term %prec HIGH {calc_trigfunc(tanh_t, $2, $$);}
-| tASINH term %prec HIGH {calc_trigfunc(asinh_t, $2, $$);}
-| tACOSH term %prec HIGH {calc_trigfunc(acosh_t, $2, $$);}
-| tATANH term %prec HIGH {calc_trigfunc(atanh_t, $2, $$);}
+| tSIN term %prec HIGH {to_rad($2, $2); mp_sin($2, $$);}
+| tCOS term %prec HIGH {to_rad($2, $2); mp_cos($2, $$);}
+| tTAN term %prec HIGH {to_rad($2, $2); mp_tan($2, $$);}
+| tASIN term %prec HIGH {mp_asin($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
+| tACOS term %prec HIGH {mp_acos($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
+| tATAN term %prec HIGH {mp_atan($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
+| tSINH term %prec HIGH {mp_sinh($2, $$);}
+| tCOSH term %prec HIGH {mp_cosh($2, $$);}
+| tTANH term %prec HIGH {mp_tanh($2, $$);}
+| tASINH term %prec HIGH {mp_asinh($2, $$);}
+| tACOSH term %prec HIGH {mp_acosh($2, $$);}
+| tATANH term %prec HIGH {mp_atanh($2, $$);}
 
-| tU32 term %prec HIGH {calc_u32($2, $$);}
-| tU16 term %prec HIGH {calc_u16($2, $$);}
+| tU32 term %prec HIGH {mp_mask_u32($2, $$);}
+| tU16 term %prec HIGH {mp_mask_u16($2, $$);}
 ;
 
 rcl:

Modified: trunk/gcalctool/ce_tokeniser.l
==============================================================================
--- trunk/gcalctool/ce_tokeniser.l	(original)
+++ trunk/gcalctool/ce_tokeniser.l	Tue Dec  2 17:09:22 2008
@@ -28,7 +28,7 @@
 #include <sys/types.h>
 #include "calctool.h"
 #include "display.h"
-#include "mpmath.h"
+#include "mp.h"
 #include "functions.h" /* FIXME: Needed for gc_strdup() */
 #include "ce_parser.h"
 #include "ce_parser.tab.h"

Modified: trunk/gcalctool/display.c
==============================================================================
--- trunk/gcalctool/display.c	(original)
+++ trunk/gcalctool/display.c	Tue Dec  2 17:09:22 2008
@@ -26,7 +26,7 @@
 
 #include "display.h"
 
-#include "mpmath.h"
+#include "mp.h"
 #include "functions.h"
 #include "ui.h"
 #include "ce_parser.h" // For ce_parse()
@@ -215,7 +215,7 @@
         text = "0";
     }
     else if (display_is_result(display)) {
-        make_number(buf, MAX_DISPLAY, display_get_answer(display), v->base, FALSE);
+        mp_cast_to_number(buf, MAX_DISPLAY, display_get_answer(display), v->base, FALSE);
         text = buf;
     }
     
@@ -237,7 +237,7 @@
         text = "0";
     }
     else if (display_is_result(display)) {
-        make_number(buf, MAX_DISPLAY, display_get_answer(display), v->base, FALSE);
+        mp_cast_to_number(buf, MAX_DISPLAY, display_get_answer(display), v->base, FALSE);
         text = buf;
     }
     
@@ -266,7 +266,7 @@
 display_set_number(GCDisplay *display, int *MPval)
 {
     if (!v->error) {
-        make_number(display->display, MAX_DISPLAY, MPval, v->base, FALSE);
+        mp_cast_to_number(display->display, MAX_DISPLAY, MPval, v->base, FALSE);
         ui_set_display(display->display, -1);
     }
 }
@@ -422,7 +422,7 @@
     /* If cursor is at end of the line then delete the last character preserving accuracy */
     if (cursor < 0) {
         if (exp_has_postfix(e->expression, "Ans")) {
-            make_number(buf, MAX_DISPLAY, e->ans, v->base, FALSE);
+            mp_cast_to_number(buf, MAX_DISPLAY, e->ans, v->base, FALSE);
             t = str_replace(e->expression, "Ans", buf);
             free(e->expression);
             e->expression = t;
@@ -431,7 +431,7 @@
                 SNPRINTF(buf, MAX_DISPLAY, "R%d", i);
                 if (exp_has_postfix(e->expression, buf)) {
                     register_get(i, MP_reg);
-                    make_number(buf2, MAX_DISPLAY, MP_reg, v->base, FALSE);
+                    mp_cast_to_number(buf2, MAX_DISPLAY, MP_reg, v->base, FALSE);
                     /* Remove "Rx" postfix and replace with backspaced number */
                     SNPRINTF(buf, MAX_DISPLAY, "%.*s%s", strlen(e->expression) - 2, e->expression - 3, buf2);
                     display_set_string(display, buf, cursor - 1);
@@ -488,14 +488,14 @@
     e = get_state(display);
     if (display_is_empty(display)) {
         mp_set_from_integer(0, MP_reg);
-        make_number(x, MAX_LOCALIZED, MP_reg, v->base, FALSE);
+        mp_cast_to_number(x, MAX_LOCALIZED, MP_reg, v->base, FALSE);
         str = x;
     } else {           
         str = strdup(e->expression);
     }
         
     /* Substitute answer register */
-    make_number(ans, MAX_LOCALIZED, e->ans, v->base, TRUE);
+    mp_cast_to_number(ans, MAX_LOCALIZED, e->ans, v->base, TRUE);
     localize_expression(localized, ans, MAX_LOCALIZED, &cursor);
     str = str_replace(str, "Ans", localized);
 
@@ -503,7 +503,7 @@
     for (i = 0; i < 10; i++) {
         SNPRINTF(reg, 3, "R%d", i);
         register_get(i, MP_reg);
-        make_number(xx, MAX_LOCALIZED, MP_reg, v->base, FALSE);
+        mp_cast_to_number(xx, MAX_LOCALIZED, MP_reg, v->base, FALSE);
         t = str_replace(str, reg, xx);
         free(str);
         str = t;

Modified: trunk/gcalctool/financial.c
==============================================================================
--- trunk/gcalctool/financial.c	(original)
+++ trunk/gcalctool/financial.c	Tue Dec  2 17:09:22 2008
@@ -19,8 +19,8 @@
  */
 
 #include "financial.h"
+#include "calctool.h"
 #include "mp.h"
-#include "mpmath.h"
 
 #include <libintl.h>
 

Modified: trunk/gcalctool/functions.c
==============================================================================
--- trunk/gcalctool/functions.c	(original)
+++ trunk/gcalctool/functions.c	Tue Dec  2 17:09:22 2008
@@ -32,7 +32,6 @@
 #include "get.h"
 #include "register.h"
 #include "mp.h"
-#include "mpmath.h"
 #include "display.h"
 #include "ce_parser.h"
 #include "ui.h"
@@ -189,14 +188,14 @@
 {
     int MPval[MP_SIZE];
 
-    if (display_is_usable_number(&v->display, MPval) || !is_integer(MPval)) {
+    if (display_is_usable_number(&v->display, MPval) || !mp_is_integer(MPval)) {
         /* Translators: This message is displayed in the status bar when a bit
            shift operation is performed and the display does not contain a number */
         ui_set_statusbar(_("No sane value to do bitwise shift"),
                          "gtk-dialog-error");
     }
     else {
-        calc_shift(MPval, display_get_answer(&v->display), count);
+        mp_shift(MPval, display_get_answer(&v->display), count);
         display_set_string(&v->display, "Ans", -1);
     }
 
@@ -377,7 +376,7 @@
             break;
 
         case FN_CONSTANT:
-            make_number(buf, MAXLINE, constant_get_value(arg), v->base, FALSE);
+            mp_cast_to_number(buf, MAXLINE, constant_get_value(arg), v->base, FALSE);
             display_insert(&v->display, buf);
             break;
 
@@ -409,7 +408,7 @@
                 MPstr_to_num(buf, 10, MP);
 
                 /* FIXME: Set as string as display_set_number doesn't store correctly */
-                make_number(buf, MAX_DISPLAY, MP, v->base, FALSE);
+                mp_cast_to_number(buf, MAX_DISPLAY, MP, v->base, FALSE);
                 display_set_string(&v->display, buf, -1);
             }
             break;

Modified: trunk/gcalctool/get.c
==============================================================================
--- trunk/gcalctool/get.c	(original)
+++ trunk/gcalctool/get.c	Tue Dec  2 17:09:22 2008
@@ -34,7 +34,7 @@
 
 #include "get.h"
 #include "register.h"
-#include "mpmath.h"
+#include "mp.h"
 
 #define EQUAL(a, b)    (strlen(a)==strlen(b)) & !strcmp(a, b) 
 

Modified: trunk/gcalctool/gtk.c
==============================================================================
--- trunk/gcalctool/gtk.c	(original)
+++ trunk/gcalctool/gtk.c	Tue Dec  2 17:09:22 2008
@@ -40,7 +40,6 @@
 #include "functions.h"
 #include "financial.h"
 #include "ce_parser.h"
-#include "mpmath.h"
 #include "display.h"
 #include "get.h"
 #include "register.h"
@@ -639,7 +638,7 @@
         N_("Hyperbolic Inverse Tangent [W]")};
     static int  tangent_functions[] = {FN_TAN, FN_ATAN, FN_TANH, FN_ATANH};
     
-	static char *ln_labels[]        = {
+    static char *ln_labels[]        = {
         /* Translators: The natural logaritm button */
         N_("Ln"),
         /* Translators: The e to the power of x button */
@@ -1390,7 +1389,7 @@
 {
     GdkScreen *screen;
     GError *error = NULL;
- 
+   
     screen = gtk_widget_get_screen (GTK_WIDGET (X->kframe));
     gtk_show_uri (screen, "ghelp:gcalctool", gtk_get_current_event_time (), &error);
  
@@ -1478,8 +1477,8 @@
             }
             else {
                 dialog_widget = gtk_widget_get_toplevel(widget);
-				if (GTK_WIDGET_TOPLEVEL (dialog_widget)) {
-                	gtk_dialog_response(GTK_DIALOG(dialog_widget),
+                if (GTK_WIDGET_TOPLEVEL (dialog_widget)) {
+                    gtk_dialog_response(GTK_DIALOG(dialog_widget),
                                         GTK_RESPONSE_OK);
                     return;
                 }
@@ -1552,9 +1551,8 @@
                              G_CALLBACK(finc_response_cb), 
                              GINT_TO_POINTER(FINC_TERM_DIALOG));
 
-	glade_xml_signal_connect(X->financial, "finc_activate_cb", 
+    glade_xml_signal_connect(X->financial, "finc_activate_cb", 
                              G_CALLBACK(finc_activate_cb));
-
 }
 
 static void
@@ -1564,7 +1562,7 @@
     int i;
 
     for (i = 0; i < MAX_CONSTANTS; i++) {
-        make_number(value, MAXLINE, constant_get_value(i), DEC, TRUE);
+        mp_cast_to_number(value, MAXLINE, constant_get_value(i), DEC, TRUE);
         SNPRINTF(mline, MAXLINE, 
                  "<span weight=\"bold\">%s_%1d:</span> %s [%s]", _("C"), i, 
                  value, 
@@ -1687,7 +1685,7 @@
     for (i = 0; i < MAX_CONSTANTS; i++) {
         gtk_list_store_append(model, &iter);
         
-        make_number(constant, MAXLINE, constant_get_value(i), DEC, TRUE);
+        mp_cast_to_number(constant, MAXLINE, constant_get_value(i), DEC, TRUE);
         gtk_list_store_set(model, &iter,
                            COLUMN_NUMBER, i,
                            COLUMN_EDITABLE, TRUE,
@@ -1735,12 +1733,12 @@
         int temp[MP_SIZE];
         
         register_get(n, temp);
-        make_number(mval, MAXLINE, temp, v->base, TRUE);
+        mp_cast_to_number(mval, MAXLINE, temp, v->base, TRUE);
         gtk_entry_set_width_chars(GTK_ENTRY(X->regs[n]), strlen(mval));
         gtk_entry_set_text(GTK_ENTRY(X->regs[n]), mval);
 
         SNPRINTF(key, MAXLINE, "register%d", n);
-        make_number(value, MAXLINE, temp, DEC, TRUE);
+        mp_cast_to_number(value, MAXLINE, temp, DEC, TRUE);
         set_resource(key, value);
     }
 }
@@ -1818,7 +1816,7 @@
     for (i = 0; i < MAX_REGISTERS; i++) {
         int temp[MP_SIZE];
         register_get(i, temp);
-        make_number(value, MAXLINE, temp, v->base, TRUE);
+        mp_cast_to_number(value, MAXLINE, temp, v->base, TRUE);
         SNPRINTF(mstr, MAXLINE, "<span weight=\"bold\">%s_%d:</span>    %s",
         /* Translators: R is the short form of register used inter alia in popup menus */
                 _("R"), i, value);

Added: trunk/gcalctool/mp-boolean.c
==============================================================================
--- (empty file)
+++ trunk/gcalctool/mp-boolean.c	Tue Dec  2 17:09:22 2008
@@ -0,0 +1,135 @@
+#include "mp.h"
+#include "calctool.h" // FIXME
+
+static char digits[] = "0123456789ABCDEF";
+
+static int hex_to_int(char digit)
+{
+    if (digit >= '0' && digit <= '9')
+        return digit - '0';
+    if (digit >= 'A' && digit <= 'F')
+        return digit - 'A' + 10;
+    if (digit >= 'a' && digit <= 'f')
+        return digit - 'a' + 10;
+    return 0;
+}
+
+
+static void
+mp_bitwise(const int s1[MP_SIZE], const int s2[MP_SIZE], int (*bitwise_operator)(int, int), int t[MP_SIZE])
+{
+    char text1[MAX_DIGITS], text2[MAX_DIGITS], text_out[MAX_DIGITS];
+    int offset1, offset2, offset_out;
+    
+    mp_cast_to_fixed(text1, MAX_DIGITS, s1, HEX, MAX_DIGITS, MAX_DIGITS);
+    mp_cast_to_fixed(text2, MAX_DIGITS, s2, HEX, MAX_DIGITS, MAX_DIGITS);
+    offset1 = strlen(text1) - 1;
+    offset2 = strlen(text2) - 1;
+    offset_out = offset1 > offset2 ? offset1 : offset2;
+    
+    /* Be at least 32 bits wide so inverse operations make sense */
+    if (offset_out < 7)
+        offset_out = 7;
+
+    /* Perform bitwise operator on each character from right to left */
+    for (text_out[offset_out+1] = '\0'; offset_out >= 0; offset_out--) {
+        int v1 = 0, v2 = 0;
+        
+        if (offset1 >= 0) {
+            v1 = hex_to_int(text1[offset1]);
+            offset1--;
+        }
+        if (offset2 >= 0) {
+            v2 = hex_to_int(text2[offset2]);
+            offset2--;
+        }
+        text_out[offset_out] = digits[bitwise_operator(v1, v2)];
+    }
+    
+    MPstr_to_num(text_out, 16, t);
+}
+
+
+static int mp_bitwise_and(int v1, int v2) { return v1 & v2; }
+static int mp_bitwise_or(int v1, int v2) { return v1 | v2; }
+static int mp_bitwise_xor(int v1, int v2) { return v1 ^ v2; }
+static int mp_bitwise_xnor(int v1, int v2) { return v1 ^ v2 ^ 0xF; }
+static int mp_bitwise_not(int v1, int dummy) { return v1 ^ 0xF; }
+
+
+void
+mp_and(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
+{
+    mp_bitwise(s1, s2, mp_bitwise_and, t);
+}
+
+
+void
+mp_or(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
+{
+    mp_bitwise(s1, s2, mp_bitwise_or, t);
+}
+
+
+void
+mp_xor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
+{
+    mp_bitwise(s1, s2, mp_bitwise_xor, t);
+}
+
+
+void
+mp_xnor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
+{
+    mp_bitwise(s1, s2, mp_bitwise_xnor, t);
+}
+
+
+void
+mp_not(const int s1[MP_SIZE], int t[MP_SIZE])
+{
+    int dummy[MP_SIZE];
+    mp_set_from_integer(0, dummy);
+    mp_bitwise(s1, dummy, mp_bitwise_not, t);    
+}
+
+
+void
+mp_mask_u32(const int s1[MP_SIZE], int t1[MP_SIZE])
+{
+    char text[MAX_DIGITS];
+    size_t len, offset;
+    
+    /* Convert to a hexadecimal string and use last 8 characters */
+    mp_cast_to_fixed(text, MAX_DIGITS, s1, HEX, MAX_DIGITS, MAX_DIGITS);
+    len = strlen(text);
+    offset = len > 8 ? len - 8: 0;
+    MPstr_to_num(text + offset, 16, t1);
+}
+
+
+void
+mp_mask_u16(const int s1[MP_SIZE], int t1[MP_SIZE])
+{
+    char text[MAX_DIGITS];
+    size_t len, offset;
+    
+    /* Convert to a hexadecimal string and use last 4 characters */
+    mp_cast_to_fixed(text, MAX_DIGITS, s1, HEX, MAX_DIGITS, MAX_DIGITS);
+    len = strlen(text);
+    offset = len > 4 ? len - 4: 0;
+    MPstr_to_num(text + offset, 16, t1);
+}
+
+
+void
+mp_shift(int s[MP_SIZE], int t[MP_SIZE], int times)
+{
+    if (times >= 0)
+        mpmuli(s, times*2, t);
+    else {
+        int temp[MP_SIZE];
+        mpdivi(s, -times*2, temp);
+        mpcmim(temp, t);
+    }
+}

Modified: trunk/gcalctool/mp-convert.c
==============================================================================
--- trunk/gcalctool/mp-convert.c	(original)
+++ trunk/gcalctool/mp-convert.c	Tue Dec  2 17:09:22 2008
@@ -30,6 +30,15 @@
 // FIXME: Needed for v->radix
 #include "calctool.h"
 
+static char digits[] = "0123456789ABCDEF";
+
+static double max_fix[MAXBASES] = {
+    1.298074214e+33,    /* Binary. */
+    2.037035976e+90,    /* Octal. */
+    1.000000000e+100,   /* Decimal */
+    2.582249878e+120    /* Hexadecimal. */
+};
+
 /*  SETS Y = X FOR MP X AND Y.
  *  SEE IF X AND Y HAVE THE SAME ADDRESS (THEY OFTEN DO)
  */
@@ -132,6 +141,12 @@
     return;
 }
 
+void
+mp_set_from_random(int t[MP_SIZE])
+{
+    mp_set_from_double(drand48(), t);
+}
+
 /*  CONVERTS DOUBLE-PRECISION NUMBER DX TO MULTIPLE-PRECISION Z.
  *  SOME NUMBERS WILL NOT CONVERT EXACTLY ON MACHINES
  *  WITH BASE OTHER THAN TWO, FOUR OR SIXTEEN.
@@ -590,3 +605,200 @@
 
     free(a);
 }
+
+
+/* Convert MP number to fixed number string in the given base to the
+ * maximum number of digits specified.
+ */
+void
+mp_cast_to_fixed(char *target, int target_len, const int *MPnumber, int base, int accuracy, int cmax)
+{
+    char *optr;
+    int MP1base[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE], MPval[MP_SIZE];
+    int ndig;                   /* Total number of digits to generate. */
+    int ddig;                   /* Number of digits to left of decimal sep. */
+    int dval, i;
+ 
+    optr = target;
+    mp_abs(MPnumber, MPval);
+    mp_set_from_integer(0, MP1);
+    if (mp_is_less_than(MPnumber, MP1)) {
+        *optr++ = '-';
+    }
+
+    mp_set_from_integer(basevals[base], MP1base);
+
+    mppwr(MP1base, accuracy, MP1);
+    MPstr_to_num("0.5", 10, MP2);
+    mpdiv(MP2, MP1, MP1);
+    mp_add(MPval, MP1, MPval);
+
+    mp_set_from_integer(1, MP2);
+    if (mp_is_less_than(MPval, MP2)) {
+        ddig = 0;
+        *optr++ = '0';
+        cmax--;
+    } else {
+        for (ddig = 0; mp_is_greater_equal(MPval, MP2); ddig++) {
+            mpdiv(MPval, MP1base, MPval);
+        }
+    }
+ 
+    ndig = (ddig + accuracy) < (--cmax) ? (ddig + accuracy) : (--cmax);
+
+    while (ndig-- > 0) {
+        if (ddig-- == 0) {
+            for (i = 0; i < strlen(v->radix); i++)
+                *optr++ = v->radix[i];
+        }
+        mpmul(MPval, MP1base, MPval);
+        dval = mp_cast_to_int(MPval);
+
+        if (dval > basevals[base]-1) {
+            dval = basevals[base]-1;
+        }
+
+        *optr++ = digits[dval];
+        dval = -dval;
+        mp_add_integer(MPval, dval, MPval);
+    }    
+    *optr++ = '\0';
+
+    /* Strip off trailing zeroes */
+    if (!v->show_zeroes) {
+        for (i = strlen(target) - 1; i > 1 && target[i] == '0'; i--) {
+            target[i] = '\0';
+        }
+        
+        /* If no fractional part discard radix */
+        if (strlen(target) >= strlen(v->radix) && strcmp(target + strlen(target) - strlen(v->radix), v->radix) == 0) {
+            target[strlen(target) - strlen(v->radix)] = '\0';
+        }
+    }
+}
+
+
+/* Convert engineering or scientific number in the given base. */
+void
+make_eng_sci(char *target, int target_len, const int *MPnumber, int base)
+{
+    char fixed[MAX_DIGITS], *optr;
+    int MP1[MP_SIZE], MPatmp[MP_SIZE], MPval[MP_SIZE];
+    int MP1base[MP_SIZE], MP3base[MP_SIZE], MP10base[MP_SIZE];
+    int i, dval, len;
+    int MPmant[MP_SIZE];        /* Mantissa. */
+    int ddig;                   /* Number of digits in exponent. */
+    int eng = 0;                /* Set if this is an engineering number. */
+    int exp = 0;                /* Exponent */
+    
+    if (v->dtype == ENG) {
+        eng = 1;
+    }
+    optr = target;
+    mp_abs(MPnumber, MPval);
+    mp_set_from_integer(0, MP1);
+    if (mp_is_less_than(MPnumber, MP1)) {
+        *optr++ = '-';
+    }
+    mp_set_from_mp(MPval, MPmant);
+
+    mp_set_from_integer(basevals[base], MP1base);
+    mppwr(MP1base, 3, MP3base);
+
+    mppwr(MP1base, 10, MP10base);
+
+    mp_set_from_integer(1, MP1);
+    mpdiv(MP1, MP10base, MPatmp);
+
+    mp_set_from_integer(0, MP1);
+    if (!mp_is_equal(MPmant, MP1)) {
+        while (!eng && mp_is_greater_equal(MPmant, MP10base)) {
+            exp += 10;
+            mpmul(MPmant, MPatmp, MPmant);
+        }
+ 
+        while ((!eng &&  mp_is_greater_equal(MPmant, MP1base)) ||
+                (eng && (mp_is_greater_equal(MPmant, MP3base) || exp % 3 != 0))) {
+            exp += 1;
+            mpdiv(MPmant, MP1base, MPmant);
+        }
+ 
+        while (!eng && mp_is_less_than(MPmant, MPatmp)) {
+            exp -= 10;
+            mpmul(MPmant, MP10base, MPmant);
+        }
+ 
+        mp_set_from_integer(1, MP1);
+        while (mp_is_less_than(MPmant, MP1) || (eng && exp % 3 != 0)) {
+            exp -= 1;
+            mpmul(MPmant, MP1base, MPmant);
+        }
+    }
+ 
+    mp_cast_to_fixed(fixed, MAX_DIGITS, MPmant, base, v->accuracy, MAX_DIGITS-6);
+    len = strlen(fixed);
+    for (i = 0; i < len; i++) {
+        *optr++ = fixed[i];
+    }
+ 
+    *optr++ = 'e';
+ 
+    if (exp < 0) {
+        exp = -exp;
+        *optr++ = '-';
+    } else {
+        *optr++ = '+';
+    }
+ 
+    MPstr_to_num("0.5", 10, MP1);
+    mp_add_integer(MP1, exp, MPval);
+    mp_set_from_integer(1, MP1);
+    for (ddig = 0; mp_is_greater_equal(MPval, MP1); ddig++) {
+        mpdiv(MPval, MP1base, MPval);
+    }
+ 
+    if (ddig == 0) {
+        *optr++ = '0';
+    }
+ 
+    while (ddig-- > 0) {
+        mpmul(MPval, MP1base, MPval);
+        dval = mp_cast_to_int(MPval);
+        *optr++ = digits[dval];
+        dval = -dval;
+        mp_add_integer(MPval, dval, MPval);
+    }
+    *optr++    = '\0';
+}
+
+
+/* Convert MP number to character string in the given base. */
+void
+mp_cast_to_number(char *target, int target_len, const int *MPnumber, int base, int ignoreError)
+{
+    double val;
+    
+    /*  NOTE: mp_cast_to_number can currently set v->error when converting to a double.
+     *        This is to provide the same look&feel as V3 even though gcalctool
+     *        now does internal arithmetic to "infinite" precision.
+     *
+     *  XXX:  Needs to be improved. Shouldn't need to convert to a double in
+     *        order to do these tests.
+     */
+
+    double number = mp_cast_to_double(MPnumber);
+
+    val = fabs(number);
+    if (v->error && !ignoreError) {
+        STRNCPY(target, _("Error"), target_len - 1);
+        return;
+    }
+    // FIXME: Do this based on the number of digits, not actual values
+    if ((v->dtype == ENG) ||
+        (v->dtype == SCI) ||
+        (v->dtype == FIX && val != 0.0 && (val > max_fix[base]))) {
+        make_eng_sci(target, target_len, MPnumber, base);
+    } else {
+        mp_cast_to_fixed(target, target_len, MPnumber, base, v->accuracy, MAX_DIGITS);
+    }
+}

Modified: trunk/gcalctool/mp.c
==============================================================================
--- trunk/gcalctool/mp.c	(original)
+++ trunk/gcalctool/mp.c	Tue Dec  2 17:09:22 2008
@@ -1,4 +1,4 @@
-
+ 
 /*  $Header$
  *
  *  Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
@@ -21,10 +21,10 @@
 
 #include <stdio.h>
 #include <math.h>
+#include <errno.h>
 
 #include "mp.h"
 #include "mp-internal.h"
-#include "mpmath.h"
 #include "calctool.h"
 #include "display.h"
 
@@ -101,7 +101,7 @@
     if (abs(sign_prod) > 1) {
         mpchk(1, 4);
         mperr("*** SIGN NOT 0, +1 OR -1 IN MPADD2 CALL.\n"
-	      "POSSIBLE OVERWRITING PROBLEM ***\n");
+              "POSSIBLE OVERWRITING PROBLEM ***\n");
         z[0] = 0;
         return;
     }
@@ -370,7 +370,7 @@
 
         /* ADD TO SUM */
         mp_add(&MP.r[i2 - 1], z, z);
-	if (MP.r[i2 - 1] == 0) break;
+        if (MP.r[i2 - 1] == 0) break;
     }
     MP.t = ts;
 }
@@ -440,7 +440,7 @@
 
     /* MOVE FRACTIONAL PART OF X TO ACCUMULATOR */
     memcpy (MP.r + offset_exp, x + (offset_exp + 2),
-	    (MP.t - offset_exp)*sizeof(int));
+            (MP.t - offset_exp)*sizeof(int));
 
     memset(MP.r + MP.t, 0, 4*sizeof(int));
 
@@ -457,9 +457,7 @@
 mpcmim(const int *x, int *y)
 {
     int tmp[MP_SIZE];     /* Temporary store for the number. */
-    int accuracy;         /* Temporary story for the accuracy. */
     char disp[MAXLINE];   /* Setup a string to store what would be displayed */
-    enum num_type dtype;  /* Setup a temp display type variable */
 
     int i, il, ll;
 
@@ -488,23 +486,12 @@
         y[i + 1] = 0;
     }
 
-    /* Fix for Sun bugtraq bug #4006391 - problem with Int function for numbers
-     * like 4800 when internal representation in something like 4799.999999999.
-     */
-    accuracy = v->accuracy;
-    dtype = v->dtype;
-
-    v->dtype = FIX;
-    v->accuracy = MAX_DIGITS;
+    // FIXME: Won't this have completely different behaviour depending on base?
     mpcmf(x, tmp);
-    make_number(disp, MAXLINE, tmp, v->base, FALSE);
-
+    mp_cast_to_fixed(disp, MAXLINE, tmp, v->base, MAX_DIGITS, MAX_DIGITS);
     if (disp[0] == '1') {
         y[ll]++;
     }
-
-    v->accuracy = accuracy;
-    v->dtype = dtype;
 }
 
 /*  COMPARES MP NUMBER X WITH REAL NUMBER RI, RETURNING
@@ -548,10 +535,10 @@
     for (i = 2; i <= t2; ++i) {
         int i2 = x[i-1] - y[i-1];
         if (i2 < 0) {
-	    /* ABS(X)  <  ABS(Y) */
+            /* ABS(X)  <  ABS(Y) */
             return -x[0];
         }
-	if (i2 > 0) {
+        if (i2 > 0) {
             /* ABS(X)  >  ABS(Y) */
             return x[0];
         }
@@ -796,6 +783,36 @@
 
 
 int
+mp_is_integer(int MPnum[MP_SIZE])
+{
+    int MPtt[MP_SIZE], MP0[MP_SIZE], MP1[MP_SIZE];
+
+    /* Multiplication and division by 10000 is used to get around a 
+     * limitation to the "fix" for Sun bugtraq bug #4006391 in the 
+     * mpcmim() routine in mp.c, when the exponent is less than 1.
+     */
+    mp_set_from_integer(10000, MPtt);
+    mpmul(MPnum, MPtt, MP0);
+    mpdiv(MP0, MPtt, MP0);
+    mpcmim(MP0, MP1);
+
+    return mp_is_equal(MP0, MP1);
+}
+
+
+int
+mp_is_natural(int MPnum[MP_SIZE])
+{    
+    int MP1[MP_SIZE];
+    if (!mp_is_integer(MPnum)) {
+        return 0;
+    }
+    mp_abs(MPnum, MP1);
+    return mp_is_equal(MPnum, MP1);
+}
+
+
+int
 mp_is_equal(const int *x, const int *y)
 {
     /* RETURNS LOGICAL VALUE OF (X == Y) FOR MP X AND Y. */
@@ -1227,6 +1244,22 @@
 }
 
 
+/*  MP precision common log.
+ *
+ *  1. log10(x) = log10(e) * log(x)
+ */
+void
+mp_logarithm(int n, int *MPx, int *MPretval)
+{
+    int MP1[MP_SIZE], MP2[MP_SIZE];
+
+    mp_set_from_integer(n, MP1);
+    mpln(MP1, MP1);
+    mpln(MPx, MP2);
+    mpdiv(MP2, MP1, MPretval);
+}
+
+
 /*  RETURNS MP Y = LN(1+X) IF X IS AN MP NUMBER SATISFYING THE
  *  CONDITION ABS(X) < 1/B, ERROR OTHERWISE.
  *  USES NEWTONS METHOD TO SOLVE THE EQUATION
@@ -1673,7 +1706,7 @@
     /* CHECK THAT SIGN = +-1 */
     if (abs(reg_sign) > 1) {
         mperr("*** SIGN NOT 0, +1 OR -1 IN CALL TO MP_GET_NORMALIZED_REGISTER.\n"
-	      "POSSIBLE OVERWRITING PROBLEM ***\n");
+              "POSSIBLE OVERWRITING PROBLEM ***\n");
         z[0] = 0;
         return;
     }
@@ -2345,3 +2378,120 @@
 
     return(pow);
 }
+
+/* Calculate the factorial of MPval. */
+void
+mp_factorial(int *MPval, int *MPres)
+{
+    double val;
+    int i, MPa[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE];
+
+    /*  NOTE: do_factorial, on each iteration of the loop, will attempt to
+     *        convert the current result to a double. If v->error is set,
+     *        then we've overflowed. This is to provide the same look&feel
+     *        as V3.
+     *
+     *  XXX:  Needs to be improved. Shouldn't need to convert to a double in
+     *        order to check this.
+     */
+    mp_set_from_mp(MPval, MPa);
+    mpcmim(MPval, MP1);
+    mp_set_from_integer(0, MP2);
+    if (mp_is_equal(MPval, MP1)
+        && mp_is_greater_equal(MPval, MP2)) {   /* Only positive integers. */
+        if (mp_is_equal(MP1, MP2)) {    /* Special case for 0! */
+            mp_set_from_integer(1, MPres);
+            return;
+        }
+        mp_set_from_integer(1, MPa);
+        i = mp_cast_to_int(MP1);
+        if (!i) {
+            matherr((struct exception *) NULL);
+        } else {
+            while (i > 0) {
+                mpmuli(MPa, i, MPa);
+                val = mp_cast_to_double(MPa);
+                if (v->error) {
+                    mperr("Error calculating factorial\n");
+                    return;
+                }
+                i--;
+            }
+        }
+    } else {
+        matherr((struct exception *) NULL);
+    }
+    mp_set_from_mp(MPa, MPres);
+}
+
+int
+mp_modulus_divide(int op1[MP_SIZE], 
+                  int op2[MP_SIZE], 
+                  int result[MP_SIZE])
+{
+    int MP1[MP_SIZE], MP2[MP_SIZE];
+
+    if (!mp_is_integer(op1) || !mp_is_integer(op2)) {
+        return -EINVAL;
+    }
+
+    mpdiv(op1, op2, MP1);
+    mpcmim(MP1, MP1);
+    mpmul(MP1, op2, MP2);
+    mp_subtract(op1, MP2, result);
+
+    mp_set_from_integer(0, MP1);
+    if ((mp_is_less_than(op2, MP1)
+         && mp_is_greater_than(result, MP1)) ||
+        mp_is_less_than(result, MP1)) { 
+        mp_add(result, op2, result);
+    }
+
+    return 0;
+}
+
+void
+mp_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]) /* Do x^y */
+{
+    int MP0[MP_SIZE];
+
+    mp_set_from_integer(0, MP0);
+
+    /* Check if both x and y are zero. If yes, then just return 1.
+     * See gcalctool bug #451286.
+     */
+    if (mp_is_equal(MPx, MP0) && mp_is_equal(MPy, MP0)) {
+        mp_set_from_integer(1, MPres);
+
+    } else if (mp_is_less_than(MPx, MP0)) {          /* Is x < 0 ? */
+        int MPtmp[MP_SIZE];
+
+        mpcmim(MPy, MPtmp);
+        if (mp_is_equal(MPtmp, MPy)) {   /* Is y == int(y) ? */
+            int y = mp_cast_to_int(MPy);
+            mppwr(MPx, y, MPres);
+        } else {        /* y != int(y). Force mppwr2 to generate an error. */
+            mppwr2(MPx, MPy, MPres);
+        }
+    } else {
+        mppwr2(MPx, MPy, MPres);
+    }
+}
+
+void
+mp_percent(int s1[MP_SIZE], int t1[MP_SIZE])
+{
+    int MP1[MP_SIZE];
+
+    MPstr_to_num("0.01", 10, MP1);
+    mpmul(s1, MP1, t1);
+}
+
+void
+mp_epowy(int s[MP_SIZE], int t[MP_SIZE])
+{
+    int MP1[MP_SIZE];
+    
+    mp_set_from_mp(s, MP1);
+    mpexp(MP1, t);
+}

Modified: trunk/gcalctool/mp.h
==============================================================================
--- trunk/gcalctool/mp.h	(original)
+++ trunk/gcalctool/mp.h	Tue Dec  2 17:09:22 2008
@@ -53,6 +53,12 @@
 
 int mp_compare_mp_to_mp(const int *x, const int *y);
 
+/* return true if parameter is integer */
+int mp_is_integer(int MPnum[MP_SIZE]);
+
+/* return true if parameter is natural number, that is, a positive integer */
+int mp_is_natural(int MPnum[MP_SIZE]);
+
 int mp_is_equal(const int *, const int *);
 int mp_is_greater_equal(const int *, const int *);
 int mp_is_greater_than(const int *, const int *);
@@ -73,6 +79,7 @@
 void mpdivi(const int *, int, int *);
 void mpexp(const int *, int *);
 void mpln(int *, int *);
+void mp_logarithm(int n, int *MPx, int *MPretval);
 void mpmul(const int *, const int *, int *);
 void mpmuli(int *, int, int *);
 void mp_get_pi(int *z);
@@ -81,6 +88,11 @@
 void mpset(int, int, int);
 void mp_root(const int *x, int n, int *z);
 void mp_sqrt(const int *x, int *z);
+void mp_factorial(int *, int *);
+int mp_modulus_divide(int op1[MP_SIZE], int op2[MP_SIZE], int result[MP_SIZE]);
+void mp_percent(int s1[MP_SIZE], int t1[MP_SIZE]);
+void mp_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]);
+void mp_epowy(int s[MP_SIZE], int t[MP_SIZE]);
 
 /* mp-convert.c */
 void   mp_set_from_mp(const int *, int *);
@@ -88,11 +100,15 @@
 void   mp_set_from_double(double, int *);
 void   mp_set_from_integer(int, int *);
 void   mp_set_from_fraction(int, int, int *);
+void   mp_set_from_random(int t[MP_SIZE]);
 float  mp_cast_to_float(const int *);
 double mp_cast_to_double(const int *);
 int    mp_cast_to_int(const int *);
+// FIXME: These should be merged together
 void   MPstr_to_num(const char *, int, int *);
-void   mp_set_from_string(const char *number, int base, int t[MP_SIZE]);
+void   mp_set_from_string(const char *number, int base, int t[MP_SIZE]); 
+void   mp_cast_to_fixed(char *, int, const int *, int, int, int);
+void   mp_cast_to_number(char *, int, const int *, int, int);
 
 /* mp-trigonometric.c */
 void mp_acos(const int *x, int *z);
@@ -108,5 +124,14 @@
 void mp_tan(const int *x, int *z);
 void mp_tanh(const int *x, int *z);
 
+/* mp-boolean.c */
+void mp_and(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void mp_or(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void mp_xor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void mp_xnor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void mp_not(const int s1[MP_SIZE], int t[MP_SIZE]);
+void mp_mask_u32(const int s1[MP_SIZE], int t1[MP_SIZE]);
+void mp_mask_u16(const int s1[MP_SIZE], int t1[MP_SIZE]);
+void mp_shift(int s[MP_SIZE], int t[MP_SIZE], int times);
 
 #endif /* MP_H */

Modified: trunk/gcalctool/register.c
==============================================================================
--- trunk/gcalctool/register.c	(original)
+++ trunk/gcalctool/register.c	Tue Dec  2 17:09:22 2008
@@ -24,7 +24,7 @@
 #include "register.h"
 #include "calctool.h"
 #include "get.h"
-#include "mpmath.h"
+#include "mp.h"
 
 static char constant_names[MAX_CONSTANTS][MAXLINE];  /* Selectable constant names. */
 static int constant_values[MAX_CONSTANTS][MP_SIZE];  /* Selectable constants. */
@@ -144,7 +144,7 @@
 
     /* NOTE: Constants are written out with no thousands separator and with a
        radix character of ".". */
-    make_number(temp, MAX_LOCALIZED, value, DEC, TRUE);   
+    mp_cast_to_number(temp, MAX_LOCALIZED, value, DEC, TRUE);   
     SNPRINTF(key, MAXLINE, "constant%1dvalue", index);
     set_resource(key, temp);
 }

Modified: trunk/gcalctool/unittest.c
==============================================================================
--- trunk/gcalctool/unittest.c	(original)
+++ trunk/gcalctool/unittest.c	Tue Dec  2 17:09:22 2008
@@ -21,7 +21,6 @@
 
 #include "unittest.h"
 
-#include "mpmath.h"
 #include "display.h"
 #include "functions.h"
 #include "calctool.h"
@@ -44,7 +43,7 @@
         return;
     }
     
-    make_fixed(result_str, MAXLINE, result, DEC, 100);
+    mp_cast_to_fixed(result_str, MAXLINE, result, DEC, 100, 100);
     if(strcmp(result_str, expected) != 0)
         printf("FAIL: '%s' -> '%s', expected '%s'\n", expression, result_str, expected);
     else

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Tue Dec  2 17:09:22 2008
@@ -10,7 +10,7 @@
 gcalctool/mp.c
 gcalctool/mp-convert.c
 gcalctool/mp-trigonometric.c
-gcalctool/mpmath.c
+gcalctool/mp-boolean.c
 gcalctool/register.c
 gcalctool.desktop.in
 glade/financial.glade



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]