[gcalctool] small tidyup



commit 8feda901704cb872369ff5c3a9c03ea306b91b7d
Author: Robert Ancell <robert ancell gmail com>
Date:   Wed Aug 26 09:12:14 2009 +1000

    small tidyup

 src/display.c |    4 ++--
 src/mp.c      |   10 ++++++----
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/display.c b/src/display.c
index 6d2280a..cdabf1a 100644
--- a/src/display.c
+++ b/src/display.c
@@ -32,9 +32,9 @@
 
 #include "get.h"
 #include "mp.h"
-#include "mp-equation.h"
 #include "functions.h"
 #include "ui.h"
+#include "mp-equation.h" // For mp_equation_parse()
 #include "register.h"
 
 static const char *display_types[] = { "ENG", "FIX", "SCI", NULL };
@@ -693,7 +693,7 @@ display_solve(GCDisplay *display, MPNumber *result)
 
 
 /* Convert engineering or scientific number in the given base. */
-void
+static void
 make_eng_sci(GCDisplay *display, char *target, int target_len, const MPNumber *MPnumber, int base)
 {
     static char digits[] = "0123456789ABCDEF";   
diff --git a/src/mp.c b/src/mp.c
index e75fd2f..45d771b 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -705,7 +705,7 @@ mp_is_equal(const MPNumber *x, const MPNumber *y)
 static void
 mpexp(const MPNumber *x, MPNumber *z)
 {
-    int i, q, ib, ic;
+    int i, q;
     float rlb;
     MPNumber t1, t2;
 
@@ -725,15 +725,17 @@ mpexp(const MPNumber *x, MPNumber *z)
     mp_set_from_mp(x, &t1);
     rlb = log((float)MP_BASE);
 
-    /* COMPUTE APPROXIMATELY OPTIMAL Q (AND DIVIDE X BY 2**Q) */
+    /* Compute approximately optimal q (and divide x by 2^q) */
     q = (int)(sqrt((float)MP_T * 0.48f * rlb) + (float) x->exponent * 1.44f * rlb);
 
     /* HALVE Q TIMES */
     if (q > 0) {
+        int ib, ic;
+
         ib = MP_BASE << 2;
         ic = 1;
         for (i = 1; i <= q; ++i) {
-            ic <<= 1;
+            ic *= 2;
             if (ic < ib && ic != MP_BASE && i < q)
                 continue;
             mp_divide_integer(&t1, ic, &t1);
@@ -761,7 +763,7 @@ mpexp(const MPNumber *x, MPNumber *z)
             break;
     }
 
-    /* APPLY (X+1)**2 - 1 = X(2 + X) FOR Q ITERATIONS */
+    /* Apply (x+1)^2 - 1 = x(2 + x) for q iterations */
     for (i = 1; i <= q; ++i) {
         mp_add_integer(z, 2, &t1);
         mp_multiply(&t1, z, z);



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