GNOME Bugzilla – Bug 524091
Tidy up mp math libraries
Last modified: 2008-12-08 14:21:55 UTC
As proposed by Klaus.Niederkrueger, bug to track patches applied.
Created attachment 107904 [details] [review] Add do_zero function for simplification The attached patch, just uses the (already existing) function do_zero at many more places. It is basically just exchanging i= 0; mpcim(&i, whatever); with do_zero(whatever);
Created attachment 107905 [details] [review] Original patch from Klaus containing large changes too big to review, will be replaced with smaller patches.
Created attachment 111207 [details] [review] Second patch from Klaus: Removed unnecessary pointers and renames mp functions
You will have to change the names of the functions as CamelCase is not the standard used in gcalctool. In addition when renaming we should use more readable names, I would recommend something more like: mpeq => mp_is_equal mplt => mp_is_less_than mpcim => mp_set_from_integer mpcmi => mp_convert_to_integer mpcdm => mp_set_from_double mpcmd => mp_convert_to_double
Created attachment 111312 [details] [review] Second patch from Klaus: Removed unnecessary pointers and renames mp functions
Created attachment 113903 [details] [review] Third patch from Klaus: mpstr and mp_abs
Refactored some of the mp functions to be more C like: http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2128
Created attachment 114098 [details] [review] Fourth patch from Klaus: Remove constants calling mpchk
Created attachment 114099 [details] [review] Fifth patch from Klaus: Remove pointer arguments to functions
Comment on attachment 111312 [details] [review] Second patch from Klaus: Removed unnecessary pointers and renames mp functions diff -Naur gcalctool.old//gcalctool/calctool.c gcalctool//gcalctool/calctool.c --- gcalctool.old//gcalctool/calctool.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/calctool.c 2008-05-21 16:59:59.000000000 +0000 @@ -682,7 +682,7 @@ static void init_state(void) { - int acc, i, n, size; + int acc, i, size; v->accuracy = DEFAULT_ACCURACY; v->show_zeroes = FALSE; /* Don't show trailing zeroes. */ @@ -712,9 +712,8 @@ init_constant(8, "0.948"); /* Kjoules <=> BTU's. */ init_constant(9, "0.0610"); /* cms3 <=> inches3. */ - n = 0; for (i = 0; i < MAX_REGISTERS; i++) { - mpcim(&n, v->MPmvals[i]); + mp_set_from_integer(0, v->MPmvals[i]); } } diff -Naur gcalctool.old//gcalctool/ce_parser.y gcalctool//gcalctool/ce_parser.y --- gcalctool.old//gcalctool/ce_parser.y 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/ce_parser.y 2008-05-21 17:17:35.000000000 +0000 @@ -127,13 +127,11 @@ display_set_number(v->MPdisp_val); } | value '=' tSTO '(' tNUMBER ')' { - int val; - mpcmi($5, &val); + int val = mp_cast_to_int($5); do_sto_reg(val, $1); } | value tSTO '(' tNUMBER ')' { - int val; - mpcmi($4, &val); + int val = mp_cast_to_int($4); do_sto_reg(val, $1); } | tCLR { @@ -261,8 +259,7 @@ rcl: tRCL '(' tNUMBER ')' { - int val; - mpcmi($3, &val); + int val = mp_cast_to_int($3); do_rcl_reg(val, $$); } ; diff -Naur gcalctool.old//gcalctool/display.c gcalctool//gcalctool/display.c --- gcalctool.old//gcalctool/display.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/display.c 2008-05-21 16:56:06.000000000 +0000 @@ -180,7 +180,7 @@ case NPA: v->ltr.pointed = 0; v->ltr.toclear = 1; - do_zero(v->MPdisp_val); + mp_set_from_integer(0, v->MPdisp_val); display_set_number(v->MPdisp_val); if (initialise == TRUE) { @@ -206,9 +206,9 @@ v->error = 0; /* Currently no display error. */ v->ltr.cur_op = -1; /* No arithmetic operator defined yet. */ v->ltr.old_cal_value = -1; - do_zero(v->MPresult); /* No previous result yet. */ - do_zero(v->MPdisp_val); - do_zero(v->MPlast_input); + mp_set_from_integer(0, v->MPresult); /* No previous result yet. */ + mp_set_from_integer(0, v->MPdisp_val); + mp_set_from_integer(0, v->MPlast_input); v->ltr.new_input = 1; /* Value zero is on calculator display */ @@ -240,7 +240,7 @@ case KEY_CLEAR: v->ltr.noparens = 0; v->ltr.cur_op = -1; - do_zero(v->MPdisp_val); + mp_set_from_integer(0, v->MPdisp_val); display_set_number(v->MPdisp_val); return; case KEY_BACKSPACE: @@ -523,7 +523,7 @@ case EXPRS: e = get_state(); if (display_is_empty()) { - do_zero(MP_reg); + mp_set_from_integer(0, MP_reg); make_number(x, MAX_LOCALIZED, MP_reg, v->base, FALSE); str = x; } else { diff -Naur gcalctool.old//gcalctool/functions.c gcalctool//gcalctool/functions.c --- gcalctool.old//gcalctool/functions.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/functions.c 2008-05-21 17:20:38.000000000 +0000 @@ -381,9 +381,10 @@ mpmul(MP1, v->MPdisp_val, MP2); mpsub(v->MPresult, MP2, v->MPresult); - do_zero(MP1); - if ((mplt(v->MPdisp_val, MP1) && mpgt(v->MPresult, MP1)) || - mplt(v->MPresult, MP1)) { + mp_set_from_integer(0, MP1); + if ((mp_is_less_than(v->MPdisp_val, MP1) + && mp_is_greater_than(v->MPresult, MP1)) || + mp_is_less_than(v->MPresult, MP1)) { mpadd(v->MPresult, v->MPdisp_val, v->MPresult); } } @@ -394,31 +395,31 @@ break; case KEY_AND: - mpcmd(v->MPresult, &dres); - mpcmd(v->MPdisp_val, &dval); + dres = mp_cast_to_double(v->MPresult); + dval = mp_cast_to_double(v->MPdisp_val); dres = setbool(ibool(dres) & ibool(dval)); - mpcdm(&dres, v->MPresult); + mp_set_from_double(dres, v->MPresult); break; case KEY_OR: - mpcmd(v->MPresult, &dres); - mpcmd(v->MPdisp_val, &dval); + dres = mp_cast_to_double(v->MPresult); + dval = mp_cast_to_double(v->MPdisp_val); dres = setbool(ibool(dres) | ibool(dval)); - mpcdm(&dres, v->MPresult); + mp_set_from_double(dres, v->MPresult); break; case KEY_XOR: - mpcmd(v->MPresult, &dres); - mpcmd(v->MPdisp_val, &dval); + dres = mp_cast_to_double(v->MPresult); + dval = mp_cast_to_double(v->MPdisp_val); dres = setbool(ibool(dres) ^ ibool(dval)); - mpcdm(&dres, v->MPresult); + mp_set_from_double(dres, v->MPresult); break; case KEY_XNOR: - mpcmd(v->MPresult, &dres); - mpcmd(v->MPdisp_val, &dval); + dres = mp_cast_to_double(v->MPresult); + dval = mp_cast_to_double(v->MPdisp_val); dres = setbool(~ibool(dres) ^ ibool(dval)); - mpcdm(&dres, v->MPresult); + mp_set_from_double(dres, v->MPresult); default: break; @@ -758,21 +759,21 @@ mpstr(MPval, MPa); mpcmim(MPval, MP1); - do_zero(MP2); - if (mpeq(MPval, MP1) && mpge(MPval, MP2)) { /* Only positive integers. */ - i = 1; - if (mpeq(MP1, MP2)) { /* Special case for 0! */ - mpcim(&i, MPres); + mp_set_from_integer(0, MP2); + if (mp_is_equal(MPval, MP1) + && mp_is_equal(MPval, MP2)) { /* Only positive integers. */ + if (mp_is_equal(MP1, MP2)) { /* Special case for 0! */ + mp_set_from_integer(1, MPres); return; } - mpcim(&i, MPa); - mpcmi(MP1, &i); + 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); - mpcmd(MPa, &val); + val = mp_cast_to_double(MPa); if (v->error) { mperr(); return; @@ -1157,7 +1158,7 @@ switch (v->syntax) { case NPA: MPstr_to_num(v->display, v->base, MPtemp); - mpcmd(MPtemp, &dval); + dval = mp_cast_to_double(MPtemp); temp = ibool(dval); if (count < 0) { @@ -1167,7 +1168,7 @@ } dval = setbool(temp); - mpcdm(&dval, v->MPdisp_val); + mp_set_from_double(dval, v->MPdisp_val); display_set_number(v->MPdisp_val); mpstr(v->MPdisp_val, v->MPlast_input); break; diff -Naur gcalctool.old//gcalctool/gtk.c gcalctool//gcalctool/gtk.c --- gcalctool.old//gcalctool/gtk.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/gtk.c 2008-05-21 17:21:24.000000000 +0000 @@ -891,7 +891,7 @@ case NPA: MPstr_to_num(v->display, v->base, MP1); mpcmim(MP1, MP2); - if (mpeq(MP1, MP2)) { + if (mp_is_equal(MP1, MP2)) { int toclear = (v->current == KEY_CLEAR_ENTRY) ? TRUE : FALSE; @@ -1226,12 +1226,10 @@ aframe_response_cb(GtkWidget *dialog, gint response_id) { char *ch; - int val; if (response_id == GTK_RESPONSE_OK) { ch = (char *) gtk_entry_get_text(GTK_ENTRY(X->aframe_ch)); - val = ch[0]; - mpcim(&val, v->MPdisp_val); + mp_set_from_integer(ch[0], v->MPdisp_val); display_set_number(v->MPdisp_val); } @@ -1733,7 +1731,7 @@ assert(FALSE); } - mpcmd(MP1, &number); + number = mp_cast_to_double(MP1); lval = (long long) number; if (lval & (1LL << n)) { @@ -1747,11 +1745,11 @@ switch (v->syntax) { case NPA: - mpcdm(&number, v->MPdisp_val); + mp_set_from_double(number, v->MPdisp_val); display_set_number(v->MPdisp_val); break; case EXPRS: - mpcdm(&number, e->ans); + mp_set_from_double(number, e->ans); display_set_string("Ans"); display_refresh(-1); break; diff -Naur gcalctool.old//gcalctool/lr_parser.y gcalctool//gcalctool/lr_parser.y --- gcalctool.old//gcalctool/lr_parser.y 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/lr_parser.y 2008-05-21 17:18:36.000000000 +0000 @@ -121,12 +121,12 @@ } | value '=' tSTO '(' tINUMBER ')' { int val; - mpcmi($5, &val); + val = mp_cast_to_int($5); do_sto_reg(val, $1); } | value tSTO '(' tINUMBER ')' { int val; - mpcmi($4, &val); + val = mp_cast_to_int($4); do_sto_reg(val, $1); } | tCLR { @@ -190,8 +190,7 @@ rcl: tRCL '(' tINUMBER ')' { - int val; - mpcmi($3, &val); + int val = mp_cast_to_int($3); do_rcl_reg(val, $$); } ; diff -Naur gcalctool.old//gcalctool/mp.c gcalctool//gcalctool/mp.c --- gcalctool.old//gcalctool/mp.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/mp.c 2008-05-21 23:23:44.000000000 +0000 @@ -78,7 +78,7 @@ static int mpcmpi(int *, int *); static int mpcmpr(int *, float *); -static int mpcomp(int *, int *); +static int mpcomp(const int *, const int *); static int pow_ii(int *, int *); static void mpadd2(int *, int *, int *, int *, int *); @@ -418,7 +418,7 @@ --x; mpchk(&c__2, &c__6); - mpcim(iy, &MP.r[MP.t + 4]); + mp_set_from_integer(*iy, &MP.r[MP.t + 4]); mpadd(&x[1], &MP.r[MP.t + 4], &z[1]); } @@ -556,7 +556,7 @@ /* HERE ABS(X) .GE. 1. SEE IF X = +-1 */ - mpcim(&x[1], &MP.r[i3 - 1]); + mp_set_from_integer(x[1], &MP.r[i3 - 1]); if (mpcomp(&x[1], &MP.r[i3 - 1]) != 0) goto L10; /* X = +-1 SO RETURN +-PI/2 */ @@ -581,7 +581,7 @@ L40: i2 = i3 - (MP.t + 2); - mpcim(&c__1, &MP.r[i2 - 1]); + mp_set_from_integer(1, &MP.r[i2 - 1]); mpstr(&MP.r[i2 - 1], &MP.r[i3 - 1]); mpsub(&MP.r[i2 - 1], &x[1], &MP.r[i2 - 1]); mpadd(&MP.r[i3 - 1], &x[1], &MP.r[i3 - 1]); @@ -698,7 +698,7 @@ void -mpcdm(double *dx, int *z) +mp_set_from_double(double dx, int *z) { int i__1; @@ -720,8 +720,8 @@ /* CHECK SIGN */ - if (*dx < 0.) goto L20; - else if (*dx == 0) goto L10; + if (dx < 0.) goto L20; + else if (dx == 0) goto L10; else goto L30; /* IF DX = 0D0 RETURN 0 */ @@ -734,14 +734,14 @@ L20: rs = -1; - dj = -(*dx); + dj = -dx; goto L40; /* DX .GT. 0D0 */ L30: rs = 1; - dj = *dx; + dj = dx; L40: ie = 0; @@ -893,11 +893,11 @@ void -mpcim(int *ix, int *z) +mp_set_from_integer(int ix, int *z) { int i__1; - static int i, n; + static int i; /* CONVERTS INTEGER IX TO MULTIPLE-PRECISION Z. * CHECK LEGALITY OF B, T, M AND MXR @@ -906,9 +906,8 @@ --z; /* Parameter adjustments */ mpchk(&c__1, &c__4); - n = *ix; - if (n < 0) goto L20; - else if (n == 0) goto L10; + if (ix < 0) goto L20; + else if (ix == 0) goto L10; else goto L30; L10: @@ -916,7 +915,7 @@ return; L20: - n = -n; + ix = -ix; z[1] = -1; goto L40; @@ -933,9 +932,9 @@ i__1 = MP.t; for (i = 2; i <= i__1; ++i) z[i + 1] = 0; -/* INSERT N */ +/* INSERT IX */ - z[MP.t + 2] = n; + z[MP.t + 2] = ix; /* NORMALIZE BY CALLING MPMUL2 */ @@ -943,16 +942,17 @@ } -void -mpcmd(int *x, double *dz) +double +mp_cast_to_double(const int *x) { int i__1; - double d__1; + double d__1, ret_val = 0.0; static int i, tm; static double db, dz2; -/* CONVERTS MULTIPLE-PRECISION X TO DOUBLE-PRECISION DZ. +/* CONVERTS MULTIPLE-PRECISION X TO DOUBLE-PRECISION, + * AND RETURNS RESULT. * ASSUMES X IS IN ALLOWABLE RANGE FOR DOUBLE-PRECISION * NUMBERS. THERE IS SOME LOSS OF ACCURACY IF THE * EXPONENT IS LARGE. @@ -962,46 +962,45 @@ --x; /* Parameter adjustments */ mpchk(&c__1, &c__4); - *dz = 0.; - if (x[1] == 0) return; + if (x[1] == 0) return 0.0; /* DB = DFLOAT(B) IS NOT ANSI STANDARD, SO USE FLOAT AND DBLE */ db = (double) ((float) MP.b); i__1 = MP.t; for (i = 1; i <= i__1; ++i) { - *dz = db * *dz + (double) ((float) x[i + 2]); + ret_val = db * ret_val + (double) ((float) x[i + 2]); tm = i; /* CHECK IF FULL DOUBLE-PRECISION ACCURACY ATTAINED */ - dz2 = *dz + 1.; + dz2 = ret_val + 1.; /* TEST BELOW NOT ALWAYS EQUIVALENT TO - IF (DZ2.LE.DZ) GO TO 20, * FOR EXAMPLE ON CYBER 76. */ - if (dz2 - *dz <= 0.) goto L20; + if (dz2 - ret_val <= 0.) goto L20; } /* NOW ALLOW FOR EXPONENT */ L20: i__1 = x[2] - tm; - *dz *= mppow_di(&db, &i__1); + ret_val *= mppow_di(&db, &i__1); /* CHECK REASONABLENESS OF RESULT. */ - if (*dz <= 0.) goto L30; + if (ret_val <= 0.) goto L30; /* LHS SHOULD BE .LE. 0.5 BUT ALLOW FOR SOME ERROR IN DLOG */ - if ((d__1 = (double) ((float) x[2]) - (log(*dz) / log((double) + if ((d__1 = (double) ((float) x[2]) - (log(ret_val) / log((double) ((float) MP.b)) + .5), C_abs(d__1)) > .6) { goto L30; } - if (x[1] < 0) *dz = -(*dz); - return; + if (x[1] < 0) ret_val = -ret_val; + return ret_val; /* FOLLOWING MESSAGE INDICATES THAT X IS TOO LARGE OR SMALL - * TRY USING MPCMDE INSTEAD. @@ -1009,10 +1008,13 @@ L30: if (v->MPerrors) { - FPRINTF(stderr, "*** FLOATING-POINT OVER/UNDER-FLOW IN MPCMD ***\n"); + FPRINTF(stderr, "*** FLOATING-POINT OVER/UNDER-FLOW IN " + "MP_CAST_TO_DOUBLE ***\n"); } mperr(); + + return 0.0; } @@ -1078,48 +1080,47 @@ } -void -mpcmi(int *x, int *iz) +int +mp_cast_to_int(const int *x) { - int i__1; - + int i__1, ret_val = 0; static int i, j, k, j1, x2, kx, xs, izs; -/* CONVERTS MULTIPLE-PRECISION X TO INTEGER IZ, +/* CONVERTS MULTIPLE-PRECISION X TO INTEGER, AND + * RETURNS RESULT. * ASSUMING THAT X NOT TOO LARGE (ELSE USE MPCMIM). * X IS TRUNCATED TOWARDS ZERO. * IF INT(X)IS TOO LARGE TO BE REPRESENTED AS A SINGLE- * PRECISION INTEGER, IZ IS RETURNED AS ZERO. THE USER * MAY CHECK FOR THIS POSSIBILITY BY TESTING IF * ((X(1).NE.0).AND.(X(2).GT.0).AND.(IZ.EQ.0)) IS TRUE ON - * RETURN FROM MPCMI. + * RETURN FROM MP_CAST_TO_INST. */ --x; /* Parameter adjustments */ xs = x[1]; - *iz = 0; - if (xs == 0) return; + if (xs == 0) return 0; - if (x[2] <= 0) return; + if (x[2] <= 0) return 0; x2 = x[2]; i__1 = x2; for (i = 1; i <= i__1; ++i) { - izs = *iz; - *iz = MP.b * *iz; - if (i <= MP.t) *iz += x[i + 2]; + izs = ret_val; + ret_val = MP.b * ret_val; + if (i <= MP.t) ret_val += x[i + 2]; /* CHECK FOR SIGNS OF INTEGER OVERFLOW */ - if (*iz <= 0 || *iz <= izs) goto L30; + if (ret_val <= 0 || ret_val <= izs) goto L30; } /* CHECK THAT RESULT IS CORRECT (AN UNDETECTED OVERFLOW MAY * HAVE OCCURRED). */ - j = *iz; + j = ret_val; i__1 = x2; for (i = 1; i <= i__1; ++i) { j1 = j / MP.b; @@ -1133,15 +1134,15 @@ /* RESULT CORRECT SO RESTORE SIGN AND RETURN */ - *iz = xs * *iz; - return; + ret_val = xs * ret_val; + return ret_val; /* HERE OVERFLOW OCCURRED (OR X WAS UNNORMALIZED), SO * RETURN ZERO. */ L30: - *iz = 0; + return 0; } @@ -1244,7 +1245,7 @@ /* CONVERT I TO MULTIPLE-PRECISION AND COMPARE */ - mpcim(i, &MP.r[MP.t + 4]); + mp_set_from_integer(*i, &MP.r[MP.t + 4]); ret_val = mpcomp(&x[1], &MP.r[MP.t + 4]); return(ret_val); } @@ -1342,7 +1343,7 @@ static int -mpcomp(int *x, int *y) +mpcomp(const int *x, const int *y) { int ret_val, i__1, i__2; @@ -1429,7 +1430,7 @@ /* COS(0) = 1 */ - mpcim(&c__1, &y[1]); + mp_set_from_integer(1, &y[1]); return; /* CHECK LEGALITY OF B, T, M AND MXR */ @@ -1478,7 +1479,7 @@ /* COSH(0) = 1 */ - mpcim(&c__1, &y[1]); + mp_set_from_integer(1, &y[1]); return; /* CHECK LEGALITY OF B, T, M AND MXR */ @@ -1536,7 +1537,7 @@ j1 = -j1; L40: - mpcim(&i1, &q[1]); + mp_set_from_integer(i1, &q[1]); if (j1 != 1) mpdivi(&q[1], &j1, &q[1]); } @@ -1955,18 +1956,10 @@ int -mpeq(int *x, int *y) +mp_is_equal(const int *x, const int *y) { - int ret_val; - -/* RETURNS LOGICAL VALUE OF (X .EQ. Y) FOR MP X AND Y. */ - - --y; /* Parameter adjustments */ - --x; - - ret_val = mpcomp(&x[1], &y[1]) == 0; - - return(ret_val); +/* RETURNS LOGICAL VALUE OF (X == Y) FOR MP X AND Y. */ + return (mpcomp(x, y) == 0); } @@ -2009,7 +2002,7 @@ /* CHECK FOR X = 0 */ if (x[1] != 0) goto L10; - mpcim(&c__1, &y[1]); + mp_set_from_integer(1, &y[1]); return; /* CHECK IF ABS(X) .LT. 1 */ @@ -2072,7 +2065,7 @@ /* GET FRACTIONAL AND INTEGER PARTS OF ABS(X) */ - mpcmi(&MP.r[i3 - 1], &ix); + ix = mp_cast_to_int(&MP.r[i3 - 1]); mpcmf(&MP.r[i3 - 1], &MP.r[i3 - 1]); /* ATTACH SIGN TO FRACTIONAL PART AND COMPUTE EXP OF IT */ @@ -2092,7 +2085,7 @@ i2 = MP.t + 5; i3 = i2 + MP.t + 2; MP.r[i3 - 1] = 0; - mpcim(&xs, &MP.r[i2 - 1]); + mp_set_from_integer(xs, &MP.r[i2 - 1]); i = 1; /* LOOP FOR E COMPUTATION. DECREASE T IF POSSIBLE. */ @@ -2356,50 +2349,26 @@ int -mpge(int *x, int *y) +mp_is_greater_equal(const int *x, const int *y) { - int ret_val; - -/* RETURNS LOGICAL VALUE OF (X .GE. Y) FOR MP X AND Y. */ - - --y; /* Parameter adjustments */ - --x; - - ret_val = mpcomp(&x[1], &y[1]) >= 0; - - return(ret_val); +/* RETURNS LOGICAL VALUE OF (X >= Y) FOR MP X AND Y. */ + return (mpcomp(x, y) >= 0); } int -mpgt(int *x, int *y) +mp_is_greater_than(const int *x, const int *y) { - int ret_val; - -/* RETURNS LOGICAL VALUE OF (X .GT. Y) FOR MP X AND Y. */ - - --y; /* Parameter adjustments */ - --x; - - ret_val = mpcomp(&x[1], &y[1]) > 0; - - return(ret_val); +/* RETURNS LOGICAL VALUE OF (X > Y) FOR MP X AND Y. */ + return (mpcomp(x, y) > 0); } int -mple(int *x, int *y) +mp_is_less_equal(const int *x, const int *y) { - int ret_val; - -/* RETURNS LOGICAL VALUE OF (X .LE. Y) FOR MP X AND Y. */ - - --y; /* Parameter adjustments */ - --x; - - ret_val = mpcomp(&x[1], &y[1]) <= 0; - - return(ret_val); +/* RETURNS LOGICAL VALUE OF (X <= Y) FOR MP X AND Y. */ + return (mpcomp(x, y) <= 0); } @@ -2609,18 +2578,10 @@ int -mplt(int *x, int *y) +mp_is_less_than(const int *x, const int *y) { - int ret_val; - -/* RETURNS LOGICAL VALUE OF (X .LT. Y) FOR MP X AND Y. */ - - --y; /* Parameter adjustments */ - --x; - - ret_val = mpcomp(&x[1], &y[1]) < 0; - - return(ret_val); +/* RETURNS LOGICAL VALUE OF (X < Y) FOR MP X AND Y. */ + return (mpcomp(x, y) < 0); } @@ -3283,7 +3244,7 @@ /* N = 0, RETURN Y = 1. */ L10: - mpcim(&c__1, &y[1]); + mp_set_from_integer(1, &y[1]); return; /* N .LT. 0 */ @@ -3324,7 +3285,7 @@ /* SET PRODUCT TERM TO ONE */ - mpcim(&c__1, &y[1]); + mp_set_from_integer(1, &y[1]); /* MAIN LOOP, LOOK AT BITS OF N2 FROM RIGHT */ @@ -3998,7 +3959,7 @@ L10: y[1] = 0; - if (*is == 0) mpcim(&c__1, &y[1]); + if (*is == 0) mp_set_from_integer(1, &y[1]); return; L20: @@ -4016,7 +3977,7 @@ goto L10; L40: - if (*is == 0) mpcim(&c__1, &MP.r[i2 - 1]); + if (*is == 0) mp_set_from_integer(1, &MP.r[i2 - 1]); if (*is != 0) mpstr(&x[1], &MP.r[i2 - 1]); y[1] = 0; @@ -4272,7 +4233,7 @@ /* HERE ABS(X) IS VERY LARGE */ - mpcim(&xs, &y[1]); + mp_set_from_integer(xs, &y[1]); return; /* HERE ABS(X) NOT SO LARGE */ diff -Naur gcalctool.old//gcalctool/mp.h gcalctool//gcalctool/mp.h --- gcalctool.old//gcalctool/mp.h 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/mp.h 2008-05-21 17:19:41.000000000 +0000 @@ -25,21 +25,24 @@ #define MP_SIZE 1000 /* Size of the multiple precision values. */ void mperr(); -int mpeq(int *, int *); -int mpge(int *, int *); -int mpgt(int *, int *); -int mple(int *, int *); -int mplt(int *, int *); + +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 *); +int mp_is_less_equal(const int *, const int *); +int mp_is_less_than(const int *, const int *); + +double mp_cast_to_double(const int *); +int mp_cast_to_int(const int *); +void mp_set_from_double(double, int *); +void mp_set_from_integer(int, int *); + void mpabs(int *, int *); void mpadd(int *, int *, int *); void mpaddi(int *, int *, int *); void mpasin(int *, int *); void mpatan(int *, int *); -void mpcdm(double *, int *); -void mpcim(int *, int *); -void mpcmd(int *, double *); void mpcmf(int *, int *); -void mpcmi(int *, int *); void mpcmim(int *, int *); void mpcos(int *, int *); void mpcosh(int *, int *); diff -Naur gcalctool.old//gcalctool/mpmath.c gcalctool//gcalctool/mpmath.c --- gcalctool.old//gcalctool/mpmath.c 2008-05-21 23:53:01.000000000 +0000 +++ gcalctool//gcalctool/mpmath.c 2008-05-21 17:21:09.000000000 +0000 @@ -62,10 +62,10 @@ { double dres, dval; - mpcmd(s1, &dres); - mpcmd(s2, &dval); + dres = mp_cast_to_double(s1); + dval = mp_cast_to_double(s2); dres = setbool(ibool(dres) & ibool(dval)); - mpcdm(&dres, t); + mp_set_from_double(dres, t); } @@ -74,10 +74,10 @@ { double dres, dval; - mpcmd(s1, &dres); - mpcmd(s2, &dval); + dres = mp_cast_to_double(s1); + dval = mp_cast_to_double(s2); dres = setbool(ibool(dres) | ibool(dval)); - mpcdm(&dres, t); + mp_set_from_double(dres, t); } @@ -86,10 +86,10 @@ { double dres, dval; - mpcmd(s1, &dres); - mpcmd(s2, &dval); + dres = mp_cast_to_double(s1); + dval = mp_cast_to_double(s2); dres = setbool(ibool(dres) ^ ibool(dval)); - mpcdm(&dres, t); + mp_set_from_double(dres, t); } @@ -98,52 +98,45 @@ { double dres, dval; - mpcmd(s1, &dres); - mpcmd(s2, &dval); + dres = mp_cast_to_double(s1); + dval = mp_cast_to_double(s2); dres = setbool(~ibool(dres) ^ ibool(dval)); - mpcdm(&dres, t); + mp_set_from_double(dres, t); } void calc_not(int s1[MP_SIZE], int t[MP_SIZE]) { - double dval; - - mpcmd(s1, &dval); + double dval = mp_cast_to_double(s1); + dval = setbool(~ibool(dval)); - mpcdm(&dval, t); + mp_set_from_double(dval, t); } void calc_rand(int t[MP_SIZE]) { - double dval = drand48(); - - mpcdm(&dval, t); + mp_set_from_double(drand48(), t); } void calc_u32(int s1[MP_SIZE], int t1[MP_SIZE]) { - double dval; - - mpcmd(s1, &dval); + double dval = mp_cast_to_double(s1); dval = setbool(ibool(dval)); - mpcdm(&dval, t1); + mp_set_from_double(dval, t1); } void calc_u16(int s1[MP_SIZE], int t1[MP_SIZE]) { - double dval; - - mpcmd(s1, &dval); + double dval = mp_cast_to_double(s1); dval = setbool(ibool(dval) & 0xffff); - mpcdm(&dval, t1); + mp_set_from_double(dval, t1); } @@ -152,9 +145,8 @@ { int MP1[MP_SIZE]; int MP2[MP_SIZE]; - int i = 1; - mpcim(&i, MP1); + mp_set_from_integer(1, MP1); mpstr(s1, MP2); mpdiv(MP1, MP2, t1); } @@ -164,9 +156,7 @@ calc_tenpowx(int s1[MP_SIZE], int t1[MP_SIZE]) /* Calculate 10^x */ { int MP1[MP_SIZE]; - int i = 10; - - mpcim(&i, MP1); + mp_set_from_integer(10, MP1); mppwr2(MP1, s1, t1); } @@ -174,25 +164,22 @@ void calc_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]) /* Do x^y */ { - int MP0[MP_SIZE], val; + int MP0[MP_SIZE]; - do_zero(MP0); + 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 (mpeq(MPx, MP0) && mpeq(MPy, MP0)) { - val = 1; - mpcim(&val, MPres); + if (mp_is_equal(MPx, MP0) && mp_is_equal(MPy, MP0)) { + mp_set_from_integer(1, MPres); - } else if (mplt(MPx, MP0)) { /* Is x < 0 ? */ + } else if (mp_is_less_than(MPx, MP0)) { /* Is x < 0 ? */ int MPtmp[MP_SIZE]; mpcmim(MPy, MPtmp); - if (mpeq(MPtmp, MPy)) { /* Is y == int(y) ? */ - int y; - - mpcmi(MPy, &y); + 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); @@ -228,8 +215,10 @@ mpmul(MP1, op2, MP2); mpsub(op1, MP2, result); - do_zero(MP1); - if ((mplt(op2, MP1) && mpgt(result, MP1)) || mplt(result, MP1)) { + 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)) { mpadd(result, op2, result); } @@ -246,20 +235,9 @@ } void -do_zero(int t1[MP_SIZE]) -{ - int i = 0; - - mpcim(&i, t1); -} - - -void do_e(int t1[MP_SIZE]) { - double e = 2.71828182846; - - mpcdm(&e, t1); + mp_set_from_double(2.71828182846, t1); } @@ -272,7 +250,7 @@ mpsin(s1, MPsin); mpcos(s1, MPcos); - mpcmd(MPcos, &cval); + cval = mp_cast_to_double(MPcos); if (cval == 0.0) { doerr(_("Error, cannot calculate cosine")); } @@ -285,19 +263,17 @@ static void to_rad(int s1[MP_SIZE], int t1[MP_SIZE]) { - int i, MP1[MP_SIZE], MP2[MP_SIZE]; + int MP1[MP_SIZE], MP2[MP_SIZE]; if (v->ttype == DEG) { mppi(MP1); mpmul(s1, MP1, MP2); - i = 180; - mpcim(&i, MP1); + mp_set_from_integer(180, MP1); mpdiv(MP2, MP1, t1); } else if (v->ttype == GRAD) { mppi(MP1); mpmul(s1, MP1, MP2); - i = 200; - mpcim(&i, MP1); + mp_set_from_integer(200, MP1); mpdiv(MP2, MP1, t1); } else { mpstr(s1, t1); @@ -308,13 +284,12 @@ static void do_trig_typeconv(enum trig_type ttype, int s1[MP_SIZE], int t1[MP_SIZE]) { - int i, MP1[MP_SIZE], MP2[MP_SIZE]; + int MP1[MP_SIZE], MP2[MP_SIZE]; switch (ttype) { case DEG: - i = 180; - mpcim(&i, MP1); + mp_set_from_integer(180, MP1); mpmul(s1, MP1, MP2); mppi(MP1); mpdiv(MP2, MP1, t1); @@ -325,8 +300,7 @@ break; case GRAD: - i = 200; - mpcim(&i, MP1); + mp_set_from_integer(200, MP1); mpmul(s1, MP1, MP2); mppi(MP1); mpdiv(MP2, MP1, t1); @@ -365,21 +339,19 @@ int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE], val; mppi(MPpi); - do_zero(MP0); - val = 1; - mpcim(&val, MP1); - val = -1; - mpcim(&val, MPn1); + mp_set_from_integer(0, MP0); + mp_set_from_integer(1, MP1); + mp_set_from_integer(-1, MPn1); - if (mpgt(MPx, MP1) || mplt(MPx, MPn1)) { + if (mp_is_greater_than(MPx, MP1) || mp_is_less_than(MPx, MPn1)) { doerr(_("Error")); mpstr(MP0, MPretval); - } else if (mpeq(MPx, MP0)) { + } else if (mp_is_equal(MPx, MP0)) { val = 2; mpdivi(MPpi, &val, MPretval); - } else if (mpeq(MPx, MP1)) { + } else if (mp_is_equal(MPx, MP1)) { mpstr(MP0, MPretval); - } else if (mpeq(MPx, MPn1)) { + } else if (mp_is_equal(MPx, MPn1)) { mpstr(MPpi, MPretval); } else { mpmul(MPx, MPx, MP2); @@ -387,7 +359,7 @@ mpsqrt(MP2, MP2); mpdiv(MP2, MPx, MP2); mpatan(MP2, MPy); - if (mpgt(MPx, MP0)) { + if (mp_is_greater_than(MPx, MP0)) { mpstr(MPy, MPretval); } else { mpadd(MPy, MPpi, MPretval); @@ -406,16 +378,15 @@ static void mpacosh(int *MPx, int *MPretval) { - int MP1[MP_SIZE], val; + int MP1[MP_SIZE]; - val = 1; - mpcim(&val, MP1); - if (mplt(MPx, MP1)) { + mp_set_from_integer(1, MP1); + if (mp_is_less_than(MPx, MP1)) { doerr(_("Error")); - do_zero(MPretval); + mp_set_from_integer(0, MPretval); } else { + int val = -1; mpmul(MPx, MPx, MP1); - val = -1; mpaddi(MP1, &val, MP1); mpsqrt(MP1, MP1); mpadd(MPx, MP1, MP1); @@ -455,15 +426,12 @@ { int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; int MP3[MP_SIZE], MPn1[MP_SIZE]; - int val; - do_zero(MP0); - val = 1; - mpcim(&val, MP1); - val = -1; - mpcim(&val, MPn1); + mp_set_from_integer(0, MP0); + mp_set_from_integer(1, MP1); + mp_set_from_integer(-1, MPn1); - if (mpge(MPx, MP1) || mple(MPx, MPn1)) { + if (mp_is_greater_equal(MPx, MP1) || mp_is_less_equal(MPx, MPn1)) { doerr(_("Error")); mpstr(MP0, MPretval); } else { @@ -487,7 +455,7 @@ { int MP1[MP_SIZE], MP2[MP_SIZE]; - mpcim(&n, MP1); + mp_set_from_integer(n, MP1); mpln(MP1, MP1); mpln(MPx, MP2); mpdiv(MP2, MP1, MPretval); @@ -540,8 +508,8 @@ int val; int MPbv[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; - do_zero(MPbv); - mpcmi(v->MPmvals[3], &len); + mp_set_from_integer(0, MPbv); + len = mp_cast_to_int(v->MPmvals[3]); for (i = 0; i < len; i++) { mpsub(v->MPmvals[0], MPbv, MP1); val = 2; @@ -648,8 +616,7 @@ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpdiv(v->MPmvals[0], v->MPmvals[1], MP1); - val = 1; - mpcim(&val, MP2); + mp_set_from_integer(1, MP2); mpdiv(MP2, v->MPmvals[2], MP3); mppwr2(MP1, MP3, MP4); val = -1; @@ -696,8 +663,7 @@ mpaddi(MP2, &val, MP3); mpaddi(v->MPmvals[2], &val, MP2); mpmul(v->MPmvals[2], MP2, MP4); - val = 2; - mpcim(&val, MP2); + mp_set_from_integer(2, MP2); mpdiv(MP4, MP2, MP1); mpdiv(MP3, MP1, MP2); mpsub(v->MPmvals[0], v->MPmvals[1], MP1); @@ -739,9 +705,8 @@ * boolean means BINARY representation */ - double dval; BOOLEAN temp; - mpcmd(s, &dval); + double dval = mp_cast_to_double(s); temp = ibool(dval); /* There is a reason to do shift like this. Reason is that @@ -762,26 +727,25 @@ } dval = setbool(temp); - mpcdm(&dval, t); + mp_set_from_double(dval, t); } int is_integer(int MPnum[MP_SIZE]) { - int i = 10000; 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. */ - mpcim(&i, MPtt); + mp_set_from_integer(10000, MPtt); mpmul(MPnum, MPtt, MP0); mpdiv(MP0, MPtt, MP0); mpcmim(MP0, MP1); - return mpeq(MP0, MP1); + return mp_is_equal(MP0, MP1); } @@ -793,7 +757,7 @@ return 0; } mpabs(MPnum, MP1); - return mpeq(MPnum, MP1); + return mp_is_equal(MPnum, MP1); } void @@ -880,16 +844,16 @@ 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, n, i; + int dval, i; optr = target; mpabs(MPnumber, MPval); - do_zero(MP1); - if (mplt(MPnumber, MP1)) { + mp_set_from_integer(0, MP1); + if (mp_is_less_than(MPnumber, MP1)) { *optr++ = '-'; } - mpcim(&basevals[base], MP1base); + mp_set_from_integer(basevals[base], MP1base); mppwr(MP1base, &v->accuracy, MP1); /* FIXME: string const. if MPstr_to_num can get it */ @@ -898,14 +862,13 @@ mpdiv(MP2, MP1, MP1); mpadd(MPval, MP1, MPval); - n = 1; - mpcim(&n, MP2); - if (mplt(MPval, MP2)) { + mp_set_from_integer(1, MP2); + if (mp_is_less_than(MPval, MP2)) { ddig = 0; *optr++ = '0'; cmax--; } else { - for (ddig = 0; mpge(MPval, MP2); ddig++) { + for (ddig = 0; mp_is_greater_equal(MPval, MP2); ddig++) { mpdiv(MPval, MP1base, MPval); } } @@ -918,7 +881,7 @@ *optr++ = v->radix[i]; } mpmul(MPval, MP1base, MPval); - mpcmi(MPval, &dval); + dval = mp_cast_to_int(MPval); if (dval > basevals[base]-1) { dval = basevals[base]-1; @@ -967,44 +930,42 @@ } optr = target; mpabs(MPnumber, MPval); - do_zero(MP1); - if (mplt(MPnumber, MP1)) { + mp_set_from_integer(0, MP1); + if (mp_is_less_than(MPnumber, MP1)) { *optr++ = '-'; } mpstr(MPval, MPmant); - mpcim(&basevals[base], MP1base); + mp_set_from_integer(basevals[base], MP1base); n = 3; mppwr(MP1base, &n, MP3base); n = 10; mppwr(MP1base, &n, MP10base); - n = 1; - mpcim(&n, MP1); + mp_set_from_integer(1, MP1); mpdiv(MP1, MP10base, MPatmp); - do_zero(MP1); - if (!mpeq(MPmant, MP1)) { - while (!eng && mpge(MPmant, MP10base)) { + 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 && mpge(MPmant, MP1base)) || - (eng && (mpge(MPmant, MP3base) || exp % 3 != 0))) { + 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 && mplt(MPmant, MPatmp)) { + while (!eng && mp_is_less_than(MPmant, MPatmp)) { exp -= 10; mpmul(MPmant, MP10base, MPmant); } - n = 1; - mpcim(&n, MP1); - while (mplt(MPmant, MP1) || (eng && exp % 3 != 0)) { + mp_set_from_integer(1, MP1); + while (mp_is_less_than(MPmant, MP1) || (eng && exp % 3 != 0)) { exp -= 1; mpmul(MPmant, MP1base, MPmant); } @@ -1028,9 +989,8 @@ SNPRINTF(half, MAXLINE, "0.5"); MPstr_to_num(half, DEC, MP1); mpaddi(MP1, &exp, MPval); - n = 1; - mpcim(&n, MP1); - for (ddig = 0; mpge(MPval, MP1); ddig++) { + mp_set_from_integer(1, MP1); + for (ddig = 0; mp_is_greater_equal(MPval, MP1); ddig++) { mpdiv(MPval, MP1base, MPval); } @@ -1040,7 +1000,7 @@ while (ddig-- > 0) { mpmul(MPval, MP1base, MPval); - mpcmi(MPval, &dval); + dval = mp_cast_to_int(MPval); *optr++ = digits[dval]; dval = -dval; mpaddi(MPval, &dval, MPval); @@ -1056,7 +1016,7 @@ void make_number(char *target, int target_len, int *MPnumber, int base, int ignoreError) { - double number, val; + double val; /* NOTE: make_number can currently set v->error when converting to a double. * This is to provide the same look&feel as V3 even though gcalctool @@ -1066,7 +1026,8 @@ * order to do these tests. */ - mpcmd(MPnumber, &number); + double number = mp_cast_to_double(MPnumber); + val = fabs(number); if (v->error && !ignoreError) { STRNCPY(target, _("Error"), target_len - 1); @@ -1110,8 +1071,8 @@ int exp_sign = 1; int negate = 0; - do_zero(MPval); - mpcim(&basevals[(int) base], MPbase); + mp_set_from_integer(0, MPval); + mp_set_from_integer(basevals[(int) base], MPbase); optr = str; @@ -1136,7 +1097,7 @@ optr++; for (i = 1; (inum = char_val(*optr)) >= 0; i++) { mppwr(MPbase, &i, MP1); - mpcim(&inum, MP2); + mp_set_from_integer(inum, MP2); mpdiv(MP2, MP1, MP1); mpadd(MPval, MP1, MPval); optr++;
Comment on attachment 107905 [details] [review] Original patch from Klaus containing large changes diff --context=2 ./calctool.c /tmp/gcalctool-5.21.4/gcalctool/./calctool.c *** ./calctool.c 2008-01-14 01:01:53.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./calctool.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 676,680 **** init_state(void) { ! int acc, i, size; v->accuracy = DEFAULT_ACCURACY; --- 676,680 ---- init_state(void) { ! int acc, i, n, size; v->accuracy = DEFAULT_ACCURACY; *************** *** 688,692 **** acc = MAX_DIGITS + 12; /* MP internal accuracy. */ size = MP_SIZE; ! mpset(acc, size, size); v->error = 0; /* No calculator error initially. */ --- 688,692 ---- acc = MAX_DIGITS + 12; /* MP internal accuracy. */ size = MP_SIZE; ! mpset(&acc, &size, &size); v->error = 0; /* No calculator error initially. */ *************** *** 709,714 **** init_constant(9, "0.0610"); /* cms3 <=> inches3. */ for (i = 0; i < MAX_REGISTERS; i++) { ! mpcim(0, v->MPmvals[i]); } --- 709,715 ---- init_constant(9, "0.0610"); /* cms3 <=> inches3. */ + n = 0; for (i = 0; i < MAX_REGISTERS; i++) { ! mpcim(&n, v->MPmvals[i]); } Only in /tmp/gcalctool-5.21.4/gcalctool/.: ce_parser.tab.h Only in .: changes.diff Only in .: .deps diff --context=2 ./display.c /tmp/gcalctool-5.21.4/gcalctool/./display.c *** ./display.c 2008-01-14 00:54:13.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./display.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 122,128 **** clear_display(int initialise) { v->pointed = 0; v->toclear = 1; ! do_zero(v->MPdisp_val); STRNCPY(v->display, make_number(v->MPdisp_val, v->base, FALSE), MAXLINE - 1); --- 122,131 ---- clear_display(int initialise) { + int i; + v->pointed = 0; v->toclear = 1; ! i = 0; ! mpcim(&i, v->MPdisp_val); STRNCPY(v->display, make_number(v->MPdisp_val, v->base, FALSE), MAXLINE - 1); *************** *** 143,152 **** initialise() { v->error = 0; /* Currently no display error. */ v->cur_op = -1; /* No arithmetic operator defined yet. */ v->old_cal_value = -1; ! do_zero(v->MPresult); /* No previous result yet. */ ! do_zero(v->MPdisp_val); ! do_zero(v->MPlast_input); v->new_input = 1; /* Value zero is on calculator display */ --- 146,158 ---- initialise() { + int i; + v->error = 0; /* Currently no display error. */ v->cur_op = -1; /* No arithmetic operator defined yet. */ v->old_cal_value = -1; ! i = 0; ! mpcim(&i, v->MPresult); /* No previous result yet. */ ! mpcim(&i, v->MPdisp_val); ! mpcim(&i, v->MPlast_input); v->new_input = 1; /* Value zero is on calculator display */ *************** *** 167,182 **** int ndig; /* Total number of digits to generate. */ int ddig; /* Number of digits to left of decimal sep. */ ! int dval; optr = str; mpabs(MPnumber, MPval); ! do_zero(MP1); if (mplt(MPnumber, MP1)) { *optr++ = '-'; } ! mpcim(basevals[base], MP1base); ! mppwr(MP1base, v->accuracy, MP1); /* FIXME: string const. if MPstr_to_num can get it */ SPRINTF(half, "0.5"); --- 173,189 ---- int ndig; /* Total number of digits to generate. */ int ddig; /* Number of digits to left of decimal sep. */ ! int dval, n; optr = str; mpabs(MPnumber, MPval); ! n = 0; ! mpcim(&n, MP1); if (mplt(MPnumber, MP1)) { *optr++ = '-'; } ! mpcim(&basevals[base], MP1base); ! mppwr(MP1base, &v->accuracy, MP1); /* FIXME: string const. if MPstr_to_num can get it */ SPRINTF(half, "0.5"); *************** *** 185,189 **** mpadd(MPval, MP1, MPval); ! mpcim(1, MP2); if (mplt(MPval, MP2)) { ddig = 0; --- 192,197 ---- mpadd(MPval, MP1, MPval); ! n = 1; ! mpcim(&n, MP2); if (mplt(MPval, MP2)) { ddig = 0; *************** *** 211,215 **** *optr++ = digits[dval]; dval = -dval; ! mpaddi(MPval, dval, MPval); } *optr++ = '\0'; --- 219,223 ---- *optr++ = digits[dval]; dval = -dval; ! mpaddi(MPval, &dval, MPval); } *optr++ = '\0'; *************** *** 272,276 **** 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. */ --- 280,284 ---- int MP1[MP_SIZE], MPatmp[MP_SIZE], MPval[MP_SIZE]; int MP1base[MP_SIZE], MP3base[MP_SIZE], MP10base[MP_SIZE]; ! int i, dval, len, n; int MPmant[MP_SIZE]; /* Mantissa. */ int ddig; /* Number of digits in exponent. */ *************** *** 283,287 **** optr = v->snum; mpabs(MPnumber, MPval); ! do_zero(MP1); if (mplt(MPnumber, MP1)) { *optr++ = '-'; --- 291,296 ---- optr = v->snum; mpabs(MPnumber, MPval); ! n = 0; ! mpcim(&n, MP1); if (mplt(MPnumber, MP1)) { *optr++ = '-'; *************** *** 289,301 **** mpstr(MPval, MPmant); ! mpcim(basevals[base], MP1base); ! mppwr(MP1base, 3, MP3base); ! mppwr(MP1base, 10, MP10base); ! mpcim(1, MP1); mpdiv(MP1, MP10base, MPatmp); ! do_zero(MP1); if (!mpeq(MPmant, MP1)) { while (!eng && mpge(MPmant, MP10base)) { --- 298,314 ---- mpstr(MPval, MPmant); ! mpcim(&basevals[base], MP1base); ! n = 3; ! mppwr(MP1base, &n, MP3base); ! n = 10; ! mppwr(MP1base, &n, MP10base); ! n = 1; ! mpcim(&n, MP1); mpdiv(MP1, MP10base, MPatmp); ! n = 0; ! mpcim(&n, MP1); if (!mpeq(MPmant, MP1)) { while (!eng && mpge(MPmant, MP10base)) { *************** *** 315,319 **** } ! mpcim(1, MP1); while (mplt(MPmant, MP1) || (eng && exp % 3 != 0)) { exp -= 1; --- 328,333 ---- } ! n = 1; ! mpcim(&n, MP1); while (mplt(MPmant, MP1) || (eng && exp % 3 != 0)) { exp -= 1; *************** *** 339,344 **** SPRINTF(half, "0.5"); MPstr_to_num(half, DEC, MP1); ! mpaddi(MP1, exp, MPval); ! mpcim(1, MP1); for (ddig = 0; mpge(MPval, MP1); ddig++) { mpdiv(MPval, MP1base, MPval); --- 353,359 ---- SPRINTF(half, "0.5"); MPstr_to_num(half, DEC, MP1); ! mpaddi(MP1, &exp, MPval); ! n = 1; ! mpcim(&n, MP1); for (ddig = 0; mpge(MPval, MP1); ddig++) { mpdiv(MPval, MP1base, MPval); *************** *** 354,358 **** *optr++ = digits[dval]; dval = -dval; ! mpaddi(MPval, dval, MPval); } *optr++ = '\0'; --- 369,373 ---- *optr++ = digits[dval]; dval = -dval; ! mpaddi(MPval, &dval, MPval); } *optr++ = '\0'; *************** *** 379,384 **** assert(lnp); ! do_zero(MPval); ! mpcim(basevals[(int) base], MPbase); optr = str; --- 394,400 ---- assert(lnp); ! i = 0; ! mpcim(&i, MPval); ! mpcim(&basevals[(int) base], MPbase); optr = str; *************** *** 397,401 **** while ((inum = char_val(*optr)) >= 0) { mpmul(MPval, MPbase, MPval); ! mpaddi(MPval, inum, MPval); optr++; } --- 413,417 ---- while ((inum = char_val(*optr)) >= 0) { mpmul(MPval, MPbase, MPval); ! mpaddi(MPval, &inum, MPval); optr++; } *************** *** 404,409 **** optr++; for (i = 1; (inum = char_val(*optr)) >= 0; i++) { ! mppwr(MPbase, i, MP1); ! mpcim(inum, MP2); mpdiv(MP2, MP1, MP1); mpadd(MPval, MP1, MPval); --- 420,425 ---- optr++; for (i = 1; (inum = char_val(*optr)) >= 0; i++) { ! mppwr(MPbase, &i, MP1); ! mpcim(&inum, MP2); mpdiv(MP2, MP1, MP1); mpadd(MPval, MP1, MPval); *************** *** 428,432 **** if (v->key_exp) { ! mppwr(MPbase, exp, MP1); mpmul(MPval, MP1, MPval); } --- 444,448 ---- if (v->key_exp) { ! mppwr(MPbase, &exp, MP1); mpmul(MPval, MP1, MPval); } *************** *** 443,447 **** paren_disp(int key) { ! int n; char *text; --- 459,463 ---- paren_disp(int key) { ! int i, n; char *text; *************** *** 463,467 **** v->noparens = v->numsptr = 0; v->cur_op = -1; ! do_zero(v->MPdisp_val); show_display(v->MPdisp_val); return; --- 479,484 ---- v->noparens = v->numsptr = 0; v->cur_op = -1; ! i = 0; ! mpcim(&i, v->MPdisp_val); show_display(v->MPdisp_val); return; diff --context=2 ./functions.c /tmp/gcalctool-5.21.4/gcalctool/./functions.c *** ./functions.c 2008-01-14 01:00:31.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./functions.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 429,432 **** --- 429,433 ---- } + i = 0; len = strlen(*str); flen = strlen(from); *************** *** 689,693 **** mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) & ibool(dval)); ! mpcdm(dres, v->MPresult); break; --- 690,694 ---- mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) & ibool(dval)); ! mpcdm(&dres, v->MPresult); break; *************** *** 696,700 **** mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) | ibool(dval)); ! mpcdm(dres, v->MPresult); break; --- 697,701 ---- mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) | ibool(dval)); ! mpcdm(&dres, v->MPresult); break; *************** *** 703,707 **** mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) ^ ibool(dval)); ! mpcdm(dres, v->MPresult); break; --- 704,708 ---- mpcmd(v->MPdisp_val, &dval); dres = setbool(ibool(dres) ^ ibool(dval)); ! mpcdm(&dres, v->MPresult); break; *************** *** 710,714 **** mpcmd(v->MPdisp_val, &dval); dres = setbool(~ibool(dres) ^ ibool(dval)); ! mpcdm(dres, v->MPresult); default: --- 711,715 ---- mpcmd(v->MPdisp_val, &dval); dres = setbool(~ibool(dres) ^ ibool(dval)); ! mpcdm(&dres, v->MPresult); default: *************** *** 1051,1061 **** mpstr(MPval, MPa); mpcmim(MPval, MP1); ! do_zero(MP2); if (mpeq(MPval, MP1) && mpge(MPval, MP2)) { /* Only positive integers. */ if (mpeq(MP1, MP2)) { /* Special case for 0! */ ! mpcim(1, MPres); return; } ! mpcim(1, MPa); mpcmi(MP1, &i); if (!i) { --- 1052,1064 ---- mpstr(MPval, MPa); mpcmim(MPval, MP1); ! i = 0; ! mpcim(&i, MP2); if (mpeq(MPval, MP1) && mpge(MPval, MP2)) { /* Only positive integers. */ + i = 1; if (mpeq(MP1, MP2)) { /* Special case for 0! */ ! mpcim(&i, MPres); return; } ! mpcim(&i, MPa); mpcmi(MP1, &i); if (!i) { *************** *** 1063,1067 **** } else { while (i > 0) { ! mpmuli(MPa, i, MPa); mpcmd(MPa, &val); if (v->error) { --- 1066,1070 ---- } else { while (i > 0) { ! mpmuli(MPa, &i, MPa); mpcmd(MPa, &val); if (v->error) { *************** *** 1455,1459 **** dval = setbool(temp); ! mpcdm(dval, v->MPdisp_val); show_display(v->MPdisp_val); mpstr(v->MPdisp_val, v->MPlast_input); --- 1458,1462 ---- dval = setbool(temp); ! mpcdm(&dval, v->MPdisp_val); show_display(v->MPdisp_val); mpstr(v->MPdisp_val, v->MPlast_input); diff --context=2 ./gtk.c /tmp/gcalctool-5.21.4/gcalctool/./gtk.c *** ./gtk.c 2008-01-11 11:31:22.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./gtk.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 1273,1277 **** ch = (char *) gtk_entry_get_text(GTK_ENTRY(X->aframe_ch)); val = ch[0]; ! mpcim(val, v->MPdisp_val); show_display(v->MPdisp_val); } --- 1273,1277 ---- ch = (char *) gtk_entry_get_text(GTK_ENTRY(X->aframe_ch)); val = ch[0]; ! mpcim(&val, v->MPdisp_val); show_display(v->MPdisp_val); } *************** *** 1767,1775 **** switch (v->syntax) { case NPA: ! mpcdm(number, v->MPdisp_val); show_display(v->MPdisp_val); break; case EXPRS: ! mpcdm(number, e->ans); exp_replace("Ans"); refresh_display(-1); --- 1767,1775 ---- switch (v->syntax) { case NPA: ! mpcdm(&number, v->MPdisp_val); show_display(v->MPdisp_val); break; case EXPRS: ! mpcdm(&number, e->ans); exp_replace("Ans"); refresh_display(-1); Only in /tmp/gcalctool-5.21.4/gcalctool/.: lr_parser.tab.h Only in .: Makefile diff --context=2 ./mp.c /tmp/gcalctool-5.21.4/gcalctool/./mp.c *** ./mp.c 2008-01-14 01:14:20.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./mp.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 54,92 **** } MP; ! static double mppow_di(double, int); ! static double mppow_ri(float, int); ! static int mppow_ii(int, int); ! ! static int mpcmpi(const int *, int); ! static int mpcmpr(const int *, float); ! static int mpcomp(const int *, const int *); ! ! static void mpadd2(const int *, const int *, int *, int, int); ! static void mpadd3(const int *, const int *, int, int, int *); ! static void mpaddq(const int *, int, int, int *); ! static void mpart1(int, int *); ! static void mpchk(int, int); ! static void mpcmr(const int *, float *); ! static void mpcqm(int, int, int *); ! static void mpcrm(float, int *); ! static void mpexp1(const int *, int *); ! static void mpext(int, int, int *); static void mpgcd(int *, int *); ! static void mplns(const int *, int *); static void mpmaxr(int *); ! static void mpmlp(int *, const int *, int, int); ! static void mpmul2(const int *, int, int *, int); ! static void mpmulq(const int *, int, int, int *); ! static void mpnzr(int, int *, int *, int); static void mpovfl(int *); static void mprec(int *, int *); ! static void mproot(int *, int, int *); ! static void mpsin1(const int *, int *, int); static void mpunfl(int *); void ! mpabs(const int *x, int *y) { --- 54,111 ---- } MP; + /* Table of constant values */ ! static int c__0 = 0; ! static int c__1 = 1; ! static int c__4 = 4; ! static int c__2 = 2; ! static int c__6 = 6; ! static int c__5 = 5; ! static int c__12 = 12; ! static int c_n2 = -2; ! static int c__10 = 10; ! static int c__32 = 32; ! static int c__3 = 3; ! static int c__8 = 8; ! static int c__14 = 14; ! static int c_n1 = -1; ! static int c__239 = 239; ! static int c__7 = 7; ! static int c__16 = 16; ! ! static double mppow_di(double *, int *); ! static double mppow_ri(float *, int *); ! ! static int mpcmpi(int *, int *); ! static int mpcmpr(int *, float *); ! static int mpcomp(int *, int *); ! static int pow_ii(int *, int *); ! ! static void mpadd2(int *, int *, int *, int *, int *); ! static void mpadd3(int *, int *, int *, int *, int *); ! static void mpaddq(int *, int *, int *, int *); ! static void mpart1(int *, int *); ! static void mpchk(int *, int *); ! static void mpcmr(int *, float *); ! static void mpcqm(int *, int *, int *); ! static void mpcrm(float *, int *); ! static void mpexp1(int *, int *); ! static void mpext(int *, int *, int *); static void mpgcd(int *, int *); ! static void mplns(int *, int *); static void mpmaxr(int *); ! static void mpmlp(int *, int *, int *, int *); ! static void mpmul2(int *, int *, int *, int *); ! static void mpmulq(int *, int *, int *, int *); ! static void mpnzr(int *, int *, int *, int *); static void mpovfl(int *); static void mprec(int *, int *); ! static void mproot(int *, int *, int *); ! static void mpsin1(int *, int *, int *); static void mpunfl(int *); void ! mpabs(int *x, int *y) { *************** *** 102,106 **** void ! mpadd(const int *x, const int *y, int *z) { --- 121,125 ---- void ! mpadd(int *x, int *y, int *z) { *************** *** 113,122 **** --x; ! mpadd2(&x[1], &y[1], &z[1], y[1], 0); } static void ! mpadd2(const int *x, const int *y, int *z, int y1, int trunc) { int i__1, i__2; --- 132,141 ---- --x; ! mpadd2(&x[1], &y[1], &z[1], &y[1], &c__0); } static void ! mpadd2(int *x, int *y, int *z, int *y1, int *trunc) { int i__1, i__2; *************** *** 127,131 **** /* CALLED BY MPADD, MPSUB ETC. * X, Y AND Z ARE MP NUMBERS, Y1 AND TRUNC ARE INTEGERS. ! * SETS Z = X + Y1*ABS(Y), WHERE Y1 = +- Y(1). * IF TRUNC.EQ.0 R*-ROUNDING IS USED, OTHERWISE TRUNCATION. * R*-ROUNDING IS DEFINED IN KUKI AND CODI, COMM. ACM --- 146,152 ---- /* CALLED BY MPADD, MPSUB ETC. * X, Y AND Z ARE MP NUMBERS, Y1 AND TRUNC ARE INTEGERS. ! * TO FORCE CALL BY REFERENCE RATHER THAN VALUE/RESULT, Y1 IS ! * DECLARED AS AN ARRAY, BUT ONLY Y1(1) IS EVER USED. ! * SETS Z = X + Y1(1)*ABS(Y), WHERE Y1(1) = +- Y(1). * IF TRUNC.EQ.0 R*-ROUNDING IS USED, OTHERWISE TRUNCATION. * R*-ROUNDING IS DEFINED IN KUKI AND CODI, COMM. ACM *************** *** 134,138 **** */ ! --z; /* Parameter adjustments */ --y; --x; --- 155,160 ---- */ ! --y1; /* Parameter adjustments */ ! --z; --y; --x; *************** *** 144,152 **** L10: mpstr(&y[1], &z[1]); ! z[1] = y1; return; L20: ! if (y1 != 0) goto L40; /* Y = 0 OR NEGLIGIBLE, SO RESULT = X */ --- 166,174 ---- L10: mpstr(&y[1], &z[1]); ! z[1] = y1[1]; return; L20: ! if (y1[1] != 0) goto L40; /* Y = 0 OR NEGLIGIBLE, SO RESULT = X */ *************** *** 159,166 **** L40: ! s = x[1] * y1; if (C_abs(s) <= 1) goto L60; ! mpchk(1, 4); if (v->MPerrors) { FPRINTF(stderr, "*** SIGN NOT 0, +1 OR -1 IN MPADD2 CALL.\nPOSSIBLE OVERWRITING PROBLEM ***\n"); --- 181,188 ---- L40: ! s = x[1] * y1[1]; if (C_abs(s) <= 1) goto L60; ! mpchk(&c__1, &c__4); if (v->MPerrors) { FPRINTF(stderr, "*** SIGN NOT 0, +1 OR -1 IN MPADD2 CALL.\nPOSSIBLE OVERWRITING PROBLEM ***\n"); *************** *** 203,214 **** L100: ! rs = y1; re = y[2]; ! mpadd3(&x[1], &y[1], s, med, &re); /* NORMALIZE, ROUND OR TRUNCATE, AND RETURN */ L110: ! mpnzr(rs, &re, &z[1], trunc); return; --- 225,236 ---- L100: ! rs = y1[1]; re = y[2]; ! mpadd3(&x[1], &y[1], &s, &med, &re); /* NORMALIZE, ROUND OR TRUNCATE, AND RETURN */ L110: ! mpnzr(&rs, &re, &z[1], trunc); return; *************** *** 221,225 **** rs = x[1]; re = x[2]; ! mpadd3(&y[1], &x[1], s, med, &re); goto L110; } --- 243,247 ---- rs = x[1]; re = x[2]; ! mpadd3(&y[1], &x[1], &s, &med, &re); goto L110; } *************** *** 227,231 **** static void ! mpadd3(const int *x, const int *y, int s, int med, int *re) { int i__1; --- 249,253 ---- static void ! mpadd3(int *x, int *y, int *s, int *med, int *re) { int i__1; *************** *** 238,242 **** --x; ! ted = MP.t + med; i2 = MP.t + 4; i = i2; --- 260,264 ---- --x; ! ted = MP.t + *med; i2 = MP.t + 4; i = i2; *************** *** 253,257 **** L20: ! if (s < 0) goto L130; /* HERE DO ADDITION, EXPONENT(Y) .GE. EXPONENT(X) */ --- 275,279 ---- L20: ! if (*s < 0) goto L130; /* HERE DO ADDITION, EXPONENT(Y) .GE. EXPONENT(X) */ *************** *** 260,264 **** L30: ! j = i - med; MP.r[i - 1] = x[j + 2]; --i; --- 282,286 ---- L30: ! j = i - *med; MP.r[i - 1] = x[j + 2]; --i; *************** *** 266,272 **** L40: ! if (i <= med) goto L60; ! j = i - med; c = y[i + 2] + x[j + 2] + c; if (c < MP.b) goto L50; --- 288,294 ---- L40: ! if (i <= *med) goto L60; ! j = i - *med; c = y[i + 2] + x[j + 2] + c; if (c < MP.b) goto L50; *************** *** 329,333 **** L110: ! j = i - med; MP.r[i - 1] = c - x[j + 2]; c = 0; --- 351,355 ---- L110: ! j = i - *med; MP.r[i - 1] = c - x[j + 2]; c = 0; *************** *** 346,352 **** L140: ! if (i <= med) goto L160; ! j = i - med; c = y[i + 2] + c - x[j + 2]; if (c >= 0) goto L150; --- 368,374 ---- L140: ! if (i <= *med) goto L160; ! j = i - *med; c = y[i + 2] + c - x[j + 2]; if (c >= 0) goto L150; *************** *** 381,385 **** void ! mpaddi(const int *x, int iy, int *z) { --- 403,407 ---- void ! mpaddi(int *x, int *iy, int *z) { *************** *** 396,400 **** --x; ! mpchk(2, 6); mpcim(iy, &MP.r[MP.t + 4]); mpadd(&x[1], &MP.r[MP.t + 4], &z[1]); --- 418,422 ---- --x; ! mpchk(&c__2, &c__6); mpcim(iy, &MP.r[MP.t + 4]); mpadd(&x[1], &MP.r[MP.t + 4], &z[1]); *************** *** 403,407 **** static void ! mpaddq(const int *x, int i, int j, int *y) { --- 425,429 ---- static void ! mpaddq(int *x, int *i, int *j, int *y) { *************** *** 414,418 **** --x; ! mpchk(2, 6); mpcqm(i, j, &MP.r[MP.t + 4]); mpadd(&x[1], &MP.r[MP.t + 4], &y[1]); --- 436,440 ---- --x; ! mpchk(&c__2, &c__6); mpcqm(i, j, &MP.r[MP.t + 4]); mpadd(&x[1], &MP.r[MP.t + 4], &y[1]); *************** *** 421,425 **** static void ! mpart1(int n, int *y) { int i__1, i__2; --- 443,447 ---- static void ! mpart1(int *n, int *y) { int i__1, i__2; *************** *** 436,441 **** --y; /* Parameter adjustments */ ! mpchk(2, 6); ! if (n > 1) goto L20; if (v->MPerrors) { --- 458,463 ---- --y; /* Parameter adjustments */ ! mpchk(&c__2, &c__6); ! if (*n > 1) goto L20; if (v->MPerrors) { *************** *** 453,457 **** /* SET SUM TO X = 1/N */ ! mpcqm(1, n, &y[1]); /* SET ADDITIVE TERM TO X */ --- 475,479 ---- /* SET SUM TO X = 1/N */ ! mpcqm(&c__1, n, &y[1]); /* SET ADDITIVE TERM TO X */ *************** *** 464,468 **** b2 = max(MP.b, 64); ! if (n < b2) id = b2 * 7 * b2 / (n * n); /* MAIN LOOP. FIRST REDUCE T IF POSSIBLE */ --- 486,490 ---- b2 = max(MP.b, 64); ! if (*n < b2) id = b2 * 7 * b2 / (*n * *n); /* MAIN LOOP. FIRST REDUCE T IF POSSIBLE */ *************** *** 481,486 **** i__1 = -i; ! i__2 = (i + 2) * n * n; ! mpmulq(&MP.r[i2 - 1], i__1, i__2, &MP.r[i2 - 1]); goto L50; --- 503,508 ---- i__1 = -i; ! i__2 = (i + 2) * *n * *n; ! mpmulq(&MP.r[i2 - 1], &i__1, &i__2, &MP.r[i2 - 1]); goto L50; *************** *** 488,492 **** i__1 = -i; i__2 = i + 2; ! mpmulq(&MP.r[i2 - 1], i__1, i__2, &MP.r[i2 - 1]); mpdivi(&MP.r[i2 - 1], n, &MP.r[i2 - 1]); mpdivi(&MP.r[i2 - 1], n, &MP.r[i2 - 1]); --- 510,514 ---- i__1 = -i; i__2 = i + 2; ! mpmulq(&MP.r[i2 - 1], &i__1, &i__2, &MP.r[i2 - 1]); mpdivi(&MP.r[i2 - 1], n, &MP.r[i2 - 1]); mpdivi(&MP.r[i2 - 1], n, &MP.r[i2 - 1]); *************** *** 501,505 **** /* ADD TO SUM, USING MPADD2 (FASTER THAN MPADD) */ ! mpadd2(&MP.r[i2 - 1], &y[1], &y[1], y[1], 0); if (MP.r[i2 - 1] != 0) goto L30; --- 523,527 ---- /* ADD TO SUM, USING MPADD2 (FASTER THAN MPADD) */ ! mpadd2(&MP.r[i2 - 1], &y[1], &y[1], &y[1], &c__0); if (MP.r[i2 - 1] != 0) goto L30; *************** *** 510,514 **** void ! mpasin(const int *x, int *y) { int i__1; --- 532,536 ---- void ! mpasin(int *x, int *y) { int i__1; *************** *** 527,531 **** --x; ! mpchk(5, 12); i3 = (MP.t << 2) + 11; if (x[1] == 0) goto L30; --- 549,553 ---- --x; ! mpchk(&c__5, &c__12); i3 = (MP.t << 2) + 11; if (x[1] == 0) goto L30; *************** *** 535,539 **** /* HERE ABS(X) .GE. 1. SEE IF X = +-1 */ ! mpcim(x[1], &MP.r[i3 - 1]); if (mpcomp(&x[1], &MP.r[i3 - 1]) != 0) goto L10; --- 557,561 ---- /* HERE ABS(X) .GE. 1. SEE IF X = +-1 */ ! mpcim(&x[1], &MP.r[i3 - 1]); if (mpcomp(&x[1], &MP.r[i3 - 1]) != 0) goto L10; *************** *** 542,546 **** mppi(&y[1]); i__1 = MP.r[i3 - 1] << 1; ! mpdivi(&y[1], i__1, &y[1]); return; --- 564,568 ---- mppi(&y[1]); i__1 = MP.r[i3 - 1] << 1; ! mpdivi(&y[1], &i__1, &y[1]); return; *************** *** 560,569 **** L40: i2 = i3 - (MP.t + 2); ! mpcim(1, &MP.r[i2 - 1]); mpstr(&MP.r[i2 - 1], &MP.r[i3 - 1]); mpsub(&MP.r[i2 - 1], &x[1], &MP.r[i2 - 1]); mpadd(&MP.r[i3 - 1], &x[1], &MP.r[i3 - 1]); mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mproot(&MP.r[i3 - 1], -2, &MP.r[i3 - 1]); mpmul(&x[1], &MP.r[i3 - 1], &y[1]); mpatan(&y[1], &y[1]); --- 582,591 ---- L40: i2 = i3 - (MP.t + 2); ! mpcim(&c__1, &MP.r[i2 - 1]); mpstr(&MP.r[i2 - 1], &MP.r[i3 - 1]); mpsub(&MP.r[i2 - 1], &x[1], &MP.r[i2 - 1]); mpadd(&MP.r[i3 - 1], &x[1], &MP.r[i3 - 1]); mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mproot(&MP.r[i3 - 1], &c_n2, &MP.r[i3 - 1]); mpmul(&x[1], &MP.r[i3 - 1], &y[1]); mpatan(&y[1], &y[1]); *************** *** 572,576 **** void ! mpatan(const int *x, int *y) { int i__1, i__2; --- 594,598 ---- void ! mpatan(int *x, int *y) { int i__1, i__2; *************** *** 594,598 **** --x; ! mpchk(5, 12); i2 = MP.t * 3 + 9; i3 = i2 + MP.t + 2; --- 616,620 ---- --x; ! mpchk(&c__5, &c__12); i2 = MP.t * 3 + 9; i3 = i2 + MP.t + 2; *************** *** 620,626 **** q <<= 1; mpmul(&MP.r[i3 - 1], &MP.r[i3 - 1], &y[1]); ! mpaddi(&y[1], 1, &y[1]); mpsqrt(&y[1], &y[1]); ! mpaddi(&y[1], 1, &y[1]); mpdiv(&MP.r[i3 - 1], &y[1], &MP.r[i3 - 1]); goto L20; --- 642,648 ---- q <<= 1; mpmul(&MP.r[i3 - 1], &MP.r[i3 - 1], &y[1]); ! mpaddi(&y[1], &c__1, &y[1]); mpsqrt(&y[1], &y[1]); ! mpaddi(&y[1], &c__1, &y[1]); mpdiv(&MP.r[i3 - 1], &y[1], &MP.r[i3 - 1]); goto L20; *************** *** 644,648 **** i__1 = -i; i__2 = i + 2; ! mpmulq(&MP.r[i3 - 1], i__1, i__2, &MP.r[i3 - 1]); i += 2; MP.t = ts; --- 666,670 ---- i__1 = -i; i__2 = i + 2; ! mpmulq(&MP.r[i3 - 1], &i__1, &i__2, &MP.r[i3 - 1]); i += 2; MP.t = ts; *************** *** 654,658 **** L50: MP.t = ts; ! mpmuli(&y[1], q, &y[1]); /* CHECK THAT RELATIVE ERROR LESS THAN 0.01 UNLESS EXPONENT --- 676,680 ---- L50: MP.t = ts; ! mpmuli(&y[1], &q, &y[1]); /* CHECK THAT RELATIVE ERROR LESS THAN 0.01 UNLESS EXPONENT *************** *** 677,681 **** void ! mpcdm(double dx, int *z) { int i__1; --- 699,703 ---- void ! mpcdm(double *dx, int *z) { int i__1; *************** *** 694,704 **** --z; /* Parameter adjustments */ ! mpchk(1, 4); i2 = MP.t + 4; /* CHECK SIGN */ ! if (dx < 0.) goto L20; ! else if (dx == 0) goto L10; else goto L30; --- 716,726 ---- --z; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); i2 = MP.t + 4; /* CHECK SIGN */ ! if (*dx < 0.) goto L20; ! else if (*dx == 0) goto L10; else goto L30; *************** *** 713,717 **** L20: rs = -1; ! dj = -(dx); goto L40; --- 735,739 ---- L20: rs = -1; ! dj = -(*dx); goto L40; *************** *** 720,724 **** L30: rs = 1; ! dj = dx; L40: --- 742,746 ---- L30: rs = 1; ! dj = *dx; L40: *************** *** 763,767 **** /* NORMALIZE RESULT */ ! mpnzr(rs, &re, &z[1], 0); /* Computing MAX */ --- 785,789 ---- /* NORMALIZE RESULT */ ! mpnzr(&rs, &re, &z[1], &c__0); /* Computing MAX */ *************** *** 783,787 **** tp <<= 4; if (tp <= ib && tp != MP.b && i < k) continue; ! mpdivi(&z[1], tp, &z[1]); tp = 1; } --- 805,809 ---- tp <<= 4; if (tp <= ib && tp != MP.b && i < k) continue; ! mpdivi(&z[1], &tp, &z[1]); tp = 1; } *************** *** 793,797 **** tp <<= 4; if (tp <= ib && tp != MP.b && i < ie) continue; ! mpmuli(&z[1], tp, &z[1]); tp = 1; } --- 815,819 ---- tp <<= 4; if (tp <= ib && tp != MP.b && i < ie) continue; ! mpmuli(&z[1], &tp, &z[1]); tp = 1; } *************** *** 803,807 **** static void ! mpchk(int i, int j) { static int ib, mx; --- 825,829 ---- static void ! mpchk(int *i, int *j) { static int ib, mx; *************** *** 854,858 **** L100: ! mx = i * MP.t + j; if (MP.mxr >= mx) return; --- 876,880 ---- L100: ! mx = *i * MP.t + *j; if (MP.mxr >= mx) return; *************** *** 864,868 **** FPRINTF(stderr, "*** MXR SHOULD BE AT LEAST %d*T + %d = %d ***\n*** ACTUALLY MXR = %d, AND T = %d ***\n", ! i, j, mx, MP.mxr, MP.t); } --- 886,890 ---- FPRINTF(stderr, "*** MXR SHOULD BE AT LEAST %d*T + %d = %d ***\n*** ACTUALLY MXR = %d, AND T = %d ***\n", ! *i, *j, mx, MP.mxr, MP.t); } *************** *** 872,876 **** void ! mpcim(int ix, int *z) { int i__1; --- 894,898 ---- void ! mpcim(int *ix, int *z) { int i__1; *************** *** 884,889 **** --z; /* Parameter adjustments */ ! mpchk(1, 4); ! n = ix; if (n < 0) goto L20; else if (n == 0) goto L10; --- 906,911 ---- --z; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); ! n = *ix; if (n < 0) goto L20; else if (n == 0) goto L10; *************** *** 918,927 **** /* NORMALIZE BY CALLING MPMUL2 */ ! mpmul2(&z[1], 1, &z[1], 1); } void ! mpcmd(const int *x, double *dz) { int i__1; --- 940,949 ---- /* NORMALIZE BY CALLING MPMUL2 */ ! mpmul2(&z[1], &c__1, &z[1], &c__1); } void ! mpcmd(int *x, double *dz) { int i__1; *************** *** 940,944 **** --x; /* Parameter adjustments */ ! mpchk(1, 4); *dz = 0.; if (x[1] == 0) return; --- 962,966 ---- --x; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); *dz = 0.; if (x[1] == 0) return; *************** *** 966,970 **** L20: i__1 = x[2] - tm; ! *dz *= mppow_di(db, i__1); /* CHECK REASONABLENESS OF RESULT. */ --- 988,992 ---- L20: i__1 = x[2] - tm; ! *dz *= mppow_di(&db, &i__1); /* CHECK REASONABLENESS OF RESULT. */ *************** *** 996,1000 **** void ! mpcmf(const int *x, int *y) { int i__1; --- 1018,1022 ---- void ! mpcmf(int *x, int *y) { int i__1; *************** *** 1053,1062 **** /* NORMALIZE RESULT AND RETURN */ ! mpnzr(xs, &x2, &y[1], 1); } void ! mpcmi(const int *x, int *iz) { int i__1; --- 1075,1084 ---- /* NORMALIZE RESULT AND RETURN */ ! mpnzr(&xs, &x2, &y[1], &c__1); } void ! mpcmi(int *x, int *iz) { int i__1; *************** *** 1125,1129 **** void ! mpcmim(const int *x, int *y) { int tmp[MP_SIZE]; /* Temporary store for the number. */ --- 1147,1151 ---- void ! mpcmim(int *x, int *y) { int tmp[MP_SIZE]; /* Temporary store for the number. */ *************** *** 1147,1151 **** --x; ! mpchk(1, 4); mpstr(&x[1], &y[1]); if (y[1] == 0) { --- 1169,1173 ---- --x; ! mpchk(&c__1, &c__4); mpstr(&x[1], &y[1]); if (y[1] == 0) { *************** *** 1205,1209 **** static int ! mpcmpi(const int *x, int i) { int ret_val; --- 1227,1231 ---- static int ! mpcmpi(int *x, int *i) { int ret_val; *************** *** 1219,1223 **** --x; /* Parameter adjustments */ ! mpchk(2, 6); /* CONVERT I TO MULTIPLE-PRECISION AND COMPARE */ --- 1241,1245 ---- --x; /* Parameter adjustments */ ! mpchk(&c__2, &c__6); /* CONVERT I TO MULTIPLE-PRECISION AND COMPARE */ *************** *** 1230,1234 **** static int ! mpcmpr(const int *x, float ri) { int ret_val; --- 1252,1256 ---- static int ! mpcmpr(int *x, float *ri) { int ret_val; *************** *** 1244,1248 **** --x; /* Parameter adjustments */ ! mpchk(2, 6); /* CONVERT RI TO MULTIPLE-PRECISION AND COMPARE */ --- 1266,1270 ---- --x; /* Parameter adjustments */ ! mpchk(&c__2, &c__6); /* CONVERT RI TO MULTIPLE-PRECISION AND COMPARE */ *************** *** 1255,1259 **** static void ! mpcmr(const int *x, float *rz) { int i__1; --- 1277,1281 ---- static void ! mpcmr(int *x, float *rz) { int i__1; *************** *** 1271,1275 **** --x; /* Parameter adjustments */ ! mpchk(1, 4); *rz = (float) 0.0; if (x[1] == 0) return; --- 1293,1297 ---- --x; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); *rz = (float) 0.0; if (x[1] == 0) return; *************** *** 1291,1295 **** L20: i__1 = x[2] - tm; ! *rz *= mppow_ri(rb, i__1); /* CHECK REASONABLENESS OF RESULT */ --- 1313,1317 ---- L20: i__1 = x[2] - tm; ! *rz *= mppow_ri(&rb, &i__1); /* CHECK REASONABLENESS OF RESULT */ *************** *** 1321,1325 **** static int ! mpcomp(const int *x, const int *y) { int ret_val, i__1, i__2; --- 1343,1347 ---- static int ! mpcomp(int *x, int *y) { int ret_val, i__1, i__2; *************** *** 1393,1397 **** void ! mpcos(const int *x, int *y) { static int i2; --- 1415,1419 ---- void ! mpcos(int *x, int *y) { static int i2; *************** *** 1408,1412 **** /* COS(0) = 1 */ ! mpcim(1, &y[1]); return; --- 1430,1434 ---- /* COS(0) = 1 */ ! mpcim(&c__1, &y[1]); return; *************** *** 1414,1418 **** L10: ! mpchk(5, 12); i2 = MP.t * 3 + 12; --- 1436,1440 ---- L10: ! mpchk(&c__5, &c__12); i2 = MP.t * 3 + 12; *************** *** 1420,1424 **** mpabs(&x[1], &y[1]); ! if (mpcmpi(&y[1], 1) <= 0) goto L20; /* HERE ABS(X) .GT. 1 SO USE COS(X) = SIN(PI/2 - ABS(X)), --- 1442,1446 ---- mpabs(&x[1], &y[1]); ! if (mpcmpi(&y[1], &c__1) <= 0) goto L20; /* HERE ABS(X) .GT. 1 SO USE COS(X) = SIN(PI/2 - ABS(X)), *************** *** 1428,1432 **** ++MP.t; mppi(&MP.r[i2 - 1]); ! mpdivi(&MP.r[i2 - 1], 2, &MP.r[i2 - 1]); --MP.t; mpsub(&MP.r[i2 - 1], &y[1], &y[1]); --- 1450,1454 ---- ++MP.t; mppi(&MP.r[i2 - 1]); ! mpdivi(&MP.r[i2 - 1], &c__2, &MP.r[i2 - 1]); --MP.t; mpsub(&MP.r[i2 - 1], &y[1], &y[1]); *************** *** 1437,1446 **** L20: ! mpsin1(&y[1], &y[1], 0); } void ! mpcosh(const int *x, int *y) { static int i2; --- 1459,1468 ---- L20: ! mpsin1(&y[1], &y[1], &c__0); } void ! mpcosh(int *x, int *y) { static int i2; *************** *** 1457,1461 **** /* COSH(0) = 1 */ ! mpcim(1, &y[1]); return; --- 1479,1483 ---- /* COSH(0) = 1 */ ! mpcim(&c__1, &y[1]); return; *************** *** 1463,1467 **** L10: ! mpchk(5, 12); i2 = (MP.t << 2) + 11; mpabs(&x[1], &MP.r[i2 - 1]); --- 1485,1489 ---- L10: ! mpchk(&c__5, &c__12); i2 = (MP.t << 2) + 11; mpabs(&x[1], &MP.r[i2 - 1]); *************** *** 1481,1490 **** MP.m += -2; ! mpdivi(&y[1], 2, &y[1]); } static void ! mpcqm(int i, int j, int *q) { static int i1, j1; --- 1503,1512 ---- MP.m += -2; ! mpdivi(&y[1], &c__2, &y[1]); } static void ! mpcqm(int *i, int *j, int *q) { static int i1, j1; *************** *** 1494,1499 **** --q; /* Parameter adjustments */ ! i1 = i; ! j1 = j; mpgcd(&i1, &j1); if (j1 < 0) goto L30; --- 1516,1521 ---- --q; /* Parameter adjustments */ ! i1 = *i; ! j1 = *j; mpgcd(&i1, &j1); if (j1 < 0) goto L30; *************** *** 1515,1525 **** L40: ! mpcim(i1, &q[1]); ! if (j1 != 1) mpdivi(&q[1], j1, &q[1]); } static void ! mpcrm(float rx, int *z) { int i__1; --- 1537,1547 ---- L40: ! mpcim(&i1, &q[1]); ! if (j1 != 1) mpdivi(&q[1], &j1, &q[1]); } static void ! mpcrm(float *rx, int *z) { int i__1; *************** *** 1536,1546 **** --z; /* Parameter adjustments */ ! mpchk(1, 4); i2 = MP.t + 4; /* CHECK SIGN */ ! if (rx < (float) 0.0) goto L20; ! else if (rx == 0) goto L10; else goto L30; --- 1558,1568 ---- --z; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); i2 = MP.t + 4; /* CHECK SIGN */ ! if (*rx < (float) 0.0) goto L20; ! else if (*rx == 0) goto L10; else goto L30; *************** *** 1555,1559 **** L20: rs = -1; ! rj = -(double)(rx); goto L40; --- 1577,1581 ---- L20: rs = -1; ! rj = -(double)(*rx); goto L40; *************** *** 1562,1566 **** L30: rs = 1; ! rj = rx; L40: --- 1584,1588 ---- L30: rs = 1; ! rj = *rx; L40: *************** *** 1602,1606 **** /* NORMALIZE RESULT */ ! mpnzr(rs, &re, &z[1], 0); /* Computing MAX */ --- 1624,1628 ---- /* NORMALIZE RESULT */ ! mpnzr(&rs, &re, &z[1], &c__0); /* Computing MAX */ *************** *** 1622,1626 **** tp <<= 4; if (tp <= ib && tp != MP.b && i < k) continue; ! mpdivi(&z[1], tp, &z[1]); tp = 1; } --- 1644,1648 ---- tp <<= 4; if (tp <= ib && tp != MP.b && i < k) continue; ! mpdivi(&z[1], &tp, &z[1]); tp = 1; } *************** *** 1632,1636 **** tp <<= 4; if (tp <= ib && tp != MP.b && i < ie) continue; ! mpmuli(&z[1], tp, &z[1]); tp = 1; } --- 1654,1658 ---- tp <<= 4; if (tp <= ib && tp != MP.b && i < ie) continue; ! mpmuli(&z[1], &tp, &z[1]); tp = 1; } *************** *** 1642,1646 **** void ! mpdiv(const int *x, int *y, int *z) { static int i, i2, ie, iz3; --- 1664,1668 ---- void ! mpdiv(int *x, int *y, int *z) { static int i, i2, ie, iz3; *************** *** 1656,1660 **** --x; ! mpchk(4, 10); /* CHECK FOR DIVISION BY ZERO */ --- 1678,1682 ---- --x; ! mpchk(&c__4, &c__10); /* CHECK FOR DIVISION BY ZERO */ *************** *** 1701,1705 **** mpmul(&x[1], &MP.r[i2 - 1], &z[1]); iz3 = z[3]; ! mpext(i, iz3, &z[1]); /* RESTORE M, CORRECT EXPONENT AND RETURN */ --- 1723,1727 ---- mpmul(&x[1], &MP.r[i2 - 1], &z[1]); iz3 = z[3]; ! mpext(&i, &iz3, &z[1]); /* RESTORE M, CORRECT EXPONENT AND RETURN */ *************** *** 1728,1732 **** void ! mpdivi(const int *x, int iy, int *z) { int i__1, i__2; --- 1750,1754 ---- void ! mpdivi(int *x, int *iy, int *z) { int i__1, i__2; *************** *** 1743,1747 **** rs = x[1]; ! j = iy; if (j < 0) goto L30; else if (j == 0) goto L10; --- 1765,1769 ---- rs = x[1]; ! j = *iy; if (j < 0) goto L30; else if (j == 0) goto L10; *************** *** 1839,1843 **** L120: ! mpnzr(rs, &re, &z[1], 0); return; --- 1861,1865 ---- L120: ! mpnzr(&rs, &re, &z[1], &c__0); return; *************** *** 1915,1919 **** L210: ! mpchk(1, 4); if (v->MPerrors) { --- 1937,1941 ---- L210: ! mpchk(&c__1, &c__4); if (v->MPerrors) { *************** *** 1934,1938 **** int ! mpeq(const int *x, const int *y) { int ret_val; --- 1956,1960 ---- int ! mpeq(int *x, int *y) { int ret_val; *************** *** 1962,1966 **** void ! mpexp(const int *x, int *y) { int i__1, i__2; --- 1984,1988 ---- void ! mpexp(int *x, int *y) { int i__1, i__2; *************** *** 1981,1985 **** --x; ! mpchk(4, 10); i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; --- 2003,2007 ---- --x; ! mpchk(&c__4, &c__10); i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; *************** *** 1988,1992 **** if (x[1] != 0) goto L10; ! mpcim(1, &y[1]); return; --- 2010,2014 ---- if (x[1] != 0) goto L10; ! mpcim(&c__1, &y[1]); return; *************** *** 1999,2003 **** mpexp1(&x[1], &y[1]); ! mpaddi(&y[1], 1, &y[1]); return; --- 2021,2025 ---- mpexp1(&x[1], &y[1]); ! mpaddi(&y[1], &c__1, &y[1]); return; *************** *** 2009,2013 **** rlb = log((float) MP.b) * (float)1.01; r__1 = -(double)((float) (MP.m + 1)) * rlb; ! if (mpcmpr(&x[1], r__1) >= 0) goto L40; /* UNDERFLOW SO CALL MPUNFL AND RETURN */ --- 2031,2035 ---- rlb = log((float) MP.b) * (float)1.01; r__1 = -(double)((float) (MP.m + 1)) * rlb; ! if (mpcmpr(&x[1], &r__1) >= 0) goto L40; /* UNDERFLOW SO CALL MPUNFL AND RETURN */ *************** *** 2019,2023 **** L40: r__1 = (float) MP.m * rlb; ! if (mpcmpr(&x[1], r__1) <= 0) goto L70; /* OVERFLOW HERE */ --- 2041,2045 ---- L40: r__1 = (float) MP.m * rlb; ! if (mpcmpr(&x[1], &r__1) <= 0) goto L70; /* OVERFLOW HERE */ *************** *** 2046,2050 **** if (dabs(rx) > (float) MP.m) { ! mpdivi(&MP.r[i3 - 1], 32, &MP.r[i3 - 1]); } --- 2068,2072 ---- if (dabs(rx) > (float) MP.m) { ! mpdivi(&MP.r[i3 - 1], &c__32, &MP.r[i3 - 1]); } *************** *** 2058,2062 **** MP.r[i3 - 1] = xs * MP.r[i3 - 1]; mpexp1(&MP.r[i3 - 1], &y[1]); ! mpaddi(&y[1], 1, &y[1]); /* COMPUTE E-2 OR 1/E USING TWO EXTRA DIGITS IN CASE ABS(X) LARGE --- 2080,2084 ---- MP.r[i3 - 1] = xs * MP.r[i3 - 1]; mpexp1(&MP.r[i3 - 1], &y[1]); ! mpaddi(&y[1], &c__1, &y[1]); /* COMPUTE E-2 OR 1/E USING TWO EXTRA DIGITS IN CASE ABS(X) LARGE *************** *** 2071,2075 **** i3 = i2 + MP.t + 2; MP.r[i3 - 1] = 0; ! mpcim(xs, &MP.r[i2 - 1]); i = 1; --- 2093,2097 ---- i3 = i2 + MP.t + 2; MP.r[i3 - 1] = 0; ! mpcim(&xs, &MP.r[i2 - 1]); i = 1; *************** *** 2085,2092 **** ++i; i__1 = i * xs; ! mpdivi(&MP.r[i2 - 1], i__1, &MP.r[i2 - 1]); MP.t = ts; ! mpadd2(&MP.r[i3 - 1], &MP.r[i2 - 1], &MP.r[i3 - 1], ! MP.r[i2 - 1], 0); if (MP.r[i2 - 1] != 0) goto L80; --- 2107,2114 ---- ++i; i__1 = i * xs; ! mpdivi(&MP.r[i2 - 1], &i__1, &MP.r[i2 - 1]); MP.t = ts; ! mpadd2(&MP.r[i3 - 1], &MP.r[i2 - 1], &MP.r[i3 - 1], & ! MP.r[i2 - 1], &c__0); if (MP.r[i2 - 1] != 0) goto L80; *************** *** 2096,2102 **** MP.t = ts; if (xs > 0) { ! mpaddi(&MP.r[i3 - 1], 2, &MP.r[i3 - 1]); } ! mppwr(&MP.r[i3 - 1], ix, &MP.r[i3 - 1]); /* RESTORE T NOW */ --- 2118,2124 ---- MP.t = ts; if (xs > 0) { ! mpaddi(&MP.r[i3 - 1], &c__2, &MP.r[i3 - 1]); } ! mppwr(&MP.r[i3 - 1], &ix, &MP.r[i3 - 1]); /* RESTORE T NOW */ *************** *** 2151,2155 **** static void ! mpexp1(const int *x, int *y) { int i__1; --- 2173,2177 ---- static void ! mpexp1(int *x, int *y) { int i__1; *************** *** 2172,2176 **** --x; ! mpchk(3, 8); i2 = MP.t + 5; i3 = i2 + MP.t + 2; --- 2194,2198 ---- --x; ! mpchk(&c__3, &c__8); i2 = MP.t + 5; i3 = i2 + MP.t + 2; *************** *** 2214,2218 **** ic <<= 1; if (ic < ib && ic != MP.b && i < q) continue; ! mpdivi(&MP.r[i2 - 1], ic, &MP.r[i2 - 1]); ic = 1; } --- 2236,2240 ---- ic <<= 1; if (ic < ib && ic != MP.b && i < q) continue; ! mpdivi(&MP.r[i2 - 1], &ic, &MP.r[i2 - 1]); ic = 1; } *************** *** 2234,2240 **** mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ++i; ! mpdivi(&MP.r[i3 - 1], i, &MP.r[i3 - 1]); MP.t = ts; ! mpadd2(&MP.r[i3 - 1], &y[1], &y[1], y[1], 0); if (MP.r[i3 - 1] != 0) goto L70; --- 2256,2262 ---- mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ++i; ! mpdivi(&MP.r[i3 - 1], &i, &MP.r[i3 - 1]); MP.t = ts; ! mpadd2(&MP.r[i3 - 1], &y[1], &y[1], &y[1], &c__0); if (MP.r[i3 - 1] != 0) goto L70; *************** *** 2247,2251 **** i__1 = q; for (i = 1; i <= i__1; ++i) { ! mpaddi(&y[1], 2, &MP.r[i2 - 1]); mpmul(&MP.r[i2 - 1], &y[1], &y[1]); } --- 2269,2273 ---- i__1 = q; for (i = 1; i <= i__1; ++i) { ! mpaddi(&y[1], &c__2, &MP.r[i2 - 1]); mpmul(&MP.r[i2 - 1], &y[1], &y[1]); } *************** *** 2254,2258 **** static void ! mpext(int i, int j, int *x) { static int q, s; --- 2276,2280 ---- static void ! mpext(int *i, int *j, int *x) { static int q, s; *************** *** 2265,2273 **** --x; /* Parameter adjustments */ ! if (x[1] == 0 || MP.t <= 2 || i == 0) return; /* COMPUTE MAXIMUM POSSIBLE ERROR IN THE LAST PLACE */ ! q = (j + 1) / i + 1; s = MP.b * x[MP.t + 1] + x[MP.t + 2]; if (s > q) goto L10; --- 2287,2295 ---- --x; /* Parameter adjustments */ ! if (x[1] == 0 || MP.t <= 2 || *i == 0) return; /* COMPUTE MAXIMUM POSSIBLE ERROR IN THE LAST PLACE */ ! q = (*j + 1) / *i + 1; s = MP.b * x[MP.t + 1] + x[MP.t + 2]; if (s > q) goto L10; *************** *** 2289,2293 **** /* NORMALIZE X (LAST DIGIT B IS OK IN MPMULI) */ ! mpmuli(&x[1], 1, &x[1]); } --- 2311,2315 ---- /* NORMALIZE X (LAST DIGIT B IS OK IN MPMULI) */ ! mpmuli(&x[1], &c__1, &x[1]); } *************** *** 2335,2339 **** int ! mpge(const int *x, const int *y) { int ret_val; --- 2357,2361 ---- int ! mpge(int *x, int *y) { int ret_val; *************** *** 2351,2355 **** int ! mpgt(const int *x, const int *y) { int ret_val; --- 2373,2377 ---- int ! mpgt(int *x, int *y) { int ret_val; *************** *** 2367,2371 **** int ! mple(const int *x, const int *y) { int ret_val; --- 2389,2393 ---- int ! mple(int *x, int *y) { int ret_val; *************** *** 2383,2387 **** void ! mpln(const int *x, int *y) { float r__1; --- 2405,2409 ---- void ! mpln(int *x, int *y) { float r__1; *************** *** 2404,2408 **** --x; ! mpchk(6, 14); i2 = (MP.t << 2) + 11; i3 = i2 + MP.t + 2; --- 2426,2430 ---- --x; ! mpchk(&c__6, &c__14); i2 = (MP.t << 2) + 11; i3 = i2 + MP.t + 2; *************** *** 2429,2433 **** L30: ! mpaddi(&MP.r[i2 - 1], -1, &MP.r[i3 - 1]); /* IF POSSIBLE GO TO CALL MPLNS */ --- 2451,2455 ---- L30: ! mpaddi(&MP.r[i2 - 1], &c_n1, &MP.r[i3 - 1]); /* IF POSSIBLE GO TO CALL MPLNS */ *************** *** 2446,2450 **** rlx = log(rx) + (float) e * log((float) MP.b); r__1 = -(double)rlx; ! mpcrm(r__1, &MP.r[i3 - 1]); /* UPDATE Y AND COMPUTE ACCURATE EXP OF APPROXIMATE LOG */ --- 2468,2472 ---- rlx = log(rx) + (float) e * log((float) MP.b); r__1 = -(double)rlx; ! mpcrm(&r__1, &MP.r[i3 - 1]); /* UPDATE Y AND COMPUTE ACCURATE EXP OF APPROXIMATE LOG */ *************** *** 2477,2481 **** static void ! mplns(const int *x, int *y) { int i__1, i__2; --- 2499,2503 ---- static void ! mplns(int *x, int *y) { int i__1, i__2; *************** *** 2495,2499 **** --x; ! mpchk(5, 12); i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; --- 2517,2521 ---- --x; ! mpchk(&c__5, &c__12); i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; *************** *** 2524,2533 **** ts = MP.t; mpstr(&x[1], &MP.r[i3 - 1]); ! mpdivi(&x[1], 4, &MP.r[i2 - 1]); ! mpaddq(&MP.r[i2 - 1], -1, 3, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddq(&MP.r[i2 - 1], 1, 2, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], -1, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &y[1]); --- 2546,2555 ---- ts = MP.t; mpstr(&x[1], &MP.r[i3 - 1]); ! mpdivi(&x[1], &c__4, &MP.r[i2 - 1]); ! mpaddq(&MP.r[i2 - 1], &c_n1, &c__3, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddq(&MP.r[i2 - 1], &c__1, &c__2, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], &c_n1, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &y[1]); *************** *** 2588,2592 **** int ! mplt(const int *x, const int *y) { int ret_val; --- 2610,2614 ---- int ! mplt(int *x, int *y) { int ret_val; *************** *** 2616,2620 **** --x; /* Parameter adjustments */ ! mpchk(1, 4); it = MP.b - 1; --- 2638,2642 ---- --x; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); it = MP.b - 1; *************** *** 2632,2637 **** static void ! mpmlp(int *u, const int *v, int w, int j) { static int i; --- 2654,2660 ---- static void ! mpmlp(int *u, int *v, int *w, int *j) { + int i__1; static int i; *************** *** 2645,2654 **** --u; ! for (i = 1; i <= j; ++i) u[i] += w * v[i]; } void ! mpmul(const int *x, const int *y, int *z) { int i__1, i__2, i__3, i__4; --- 2668,2678 ---- --u; ! i__1 = *j; ! for (i = 1; i <= i__1; ++i) u[i] += *w * v[i]; } void ! mpmul(int *x, int *y, int *z) { int i__1, i__2, i__3, i__4; *************** *** 2674,2678 **** --x; ! mpchk(1, 4); i2 = MP.t + 4; i2p = i2 + 1; --- 2698,2702 ---- --x; ! mpchk(&c__1, &c__4); i2 = MP.t + 4; i2p = i2 + 1; *************** *** 2713,2717 **** i__3 = MP.t, i__4 = i2 - i; i__2 = min(i__3,i__4); ! mpmlp(&MP.r[i], &y[3], xi, i__2); --c; if (c > 0) continue; --- 2737,2741 ---- i__3 = MP.t, i__4 = i2 - i; i__2 = min(i__3,i__4); ! mpmlp(&MP.r[i], &y[3], &xi, &i__2); --c; if (c > 0) continue; *************** *** 2753,2757 **** L60: ! mpnzr(rs, &re, &z[1], 0); return; --- 2777,2781 ---- L60: ! mpnzr(&rs, &re, &z[1], &c__0); return; *************** *** 2775,2779 **** static void ! mpmul2(const int *x, int iy, int *z, int trunc) { int i__1, i__2; --- 2799,2803 ---- static void ! mpmul2(int *x, int *iy, int *z, int *trunc) { int i__1, i__2; *************** *** 2793,2797 **** rs = x[1]; if (rs == 0) goto L10; ! j = iy; if (j < 0) goto L20; else if (j == 0) goto L10; --- 2817,2821 ---- rs = x[1]; if (rs == 0) goto L10; ! j = *iy; if (j < 0) goto L20; else if (j == 0) goto L10; *************** *** 2813,2817 **** if (x[2] < MP.m) goto L40; ! mpchk(1, 4); if (v->MPerrors) { --- 2837,2841 ---- if (x[2] < MP.m) goto L40; ! mpchk(&c__1, &c__4); if (v->MPerrors) { *************** *** 2890,2894 **** L100: ! mpnzr(rs, &re, &z[1], trunc); return; --- 2914,2918 ---- L100: ! mpnzr(&rs, &re, &z[1], trunc); return; *************** *** 2921,2925 **** L130: ! mpchk(1, 4); if (v->MPerrors) { --- 2945,2949 ---- L130: ! mpchk(&c__1, &c__4); if (v->MPerrors) { *************** *** 2933,2937 **** void ! mpmuli(const int *x, int iy, int *z) { --- 2957,2961 ---- void ! mpmuli(int *x, int *iy, int *z) { *************** *** 2945,2954 **** --x; ! mpmul2(&x[1], iy, &z[1], 0); } static void ! mpmulq(const int *x, int i, int j, int *y) { int i__1; --- 2969,2978 ---- --x; ! mpmul2(&x[1], iy, &z[1], &c__0); } static void ! mpmulq(int *x, int *i, int *j, int *y) { int i__1; *************** *** 2961,2966 **** --x; ! if (j != 0) goto L20; ! mpchk(1, 4); if (v->MPerrors) { --- 2985,2990 ---- --x; ! if (*j != 0) goto L20; ! mpchk(&c__1, &c__4); if (v->MPerrors) { *************** *** 2972,2976 **** L20: ! if (i != 0) goto L40; L30: --- 2996,3000 ---- L20: ! if (*i != 0) goto L40; L30: *************** *** 2981,2991 **** L40: ! is = i; ! js = j; mpgcd(&is, &js); if (C_abs(is) == 1) goto L50; ! mpdivi(&x[1], js, &y[1]); ! mpmul2(&y[1], is, &y[1], 0); return; --- 3005,3015 ---- L40: ! is = *i; ! js = *j; mpgcd(&is, &js); if (C_abs(is) == 1) goto L50; ! mpdivi(&x[1], &js, &y[1]); ! mpmul2(&y[1], &is, &y[1], &c__0); return; *************** *** 2994,3003 **** L50: i__1 = is * js; ! mpdivi(&x[1], i__1, &y[1]); } void ! mpneg(const int *x, int *y) { --- 3018,3027 ---- L50: i__1 = is * js; ! mpdivi(&x[1], &i__1, &y[1]); } void ! mpneg(int *x, int *y) { *************** *** 3013,3017 **** static void ! mpnzr(int rs, int *re, int *z, int trunc) { int i__1; --- 3037,3041 ---- static void ! mpnzr(int *rs, int *re, int *z, int *trunc) { int i__1; *************** *** 3028,3032 **** i2 = MP.t + 4; ! if (rs != 0) goto L20; /* STORE ZERO IN Z */ --- 3052,3056 ---- i2 = MP.t + 4; ! if (*rs != 0) goto L20; /* STORE ZERO IN Z */ *************** *** 3039,3043 **** L20: ! if (C_abs(rs) <= 1) goto L40; if (v->MPerrors) { --- 3063,3067 ---- L20: ! if (C_abs(*rs) <= 1) goto L40; if (v->MPerrors) { *************** *** 3080,3084 **** L90: ! if (trunc != 0) goto L150; /* SEE IF ROUNDING NECESSARY --- 3104,3108 ---- L90: ! if (*trunc != 0) goto L150; /* SEE IF ROUNDING NECESSARY *************** *** 3150,3154 **** /* STORE RESULT IN Z */ ! z[1] = rs; z[2] = *re; i__1 = MP.t; --- 3174,3178 ---- /* STORE RESULT IN Z */ ! z[1] = *rs; z[2] = *re; i__1 = MP.t; *************** *** 3179,3183 **** --x; /* Parameter adjustments */ ! mpchk(1, 4); /* SET X TO LARGEST POSSIBLE POSITIVE NUMBER */ --- 3203,3207 ---- --x; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); /* SET X TO LARGEST POSSIBLE POSITIVE NUMBER */ *************** *** 3212,3225 **** --x; /* Parameter adjustments */ ! mpchk(3, 8); /* ALLOW SPACE FOR MPART1 */ i2 = (MP.t << 1) + 7; ! mpart1(5, &MP.r[i2 - 1]); ! mpmuli(&MP.r[i2 - 1], 4, &MP.r[i2 - 1]); ! mpart1(239, &x[1]); mpsub(&MP.r[i2 - 1], &x[1], &x[1]); ! mpmuli(&x[1], 4, &x[1]); /* RETURN IF ERROR IS LESS THAN 0.01 */ --- 3236,3249 ---- --x; /* Parameter adjustments */ ! mpchk(&c__3, &c__8); /* ALLOW SPACE FOR MPART1 */ i2 = (MP.t << 1) + 7; ! mpart1(&c__5, &MP.r[i2 - 1]); ! mpmuli(&MP.r[i2 - 1], &c__4, &MP.r[i2 - 1]); ! mpart1(&c__239, &x[1]); mpsub(&MP.r[i2 - 1], &x[1], &x[1]); ! mpmuli(&x[1], &c__4, &x[1]); /* RETURN IF ERROR IS LESS THAN 0.01 */ *************** *** 3239,3243 **** void ! mppwr(const int *x, int n, int *y) { static int i2, n2, ns; --- 3263,3267 ---- void ! mppwr(int *x, int *n, int *y) { static int i2, n2, ns; *************** *** 3252,3256 **** i2 = MP.t + 5; ! n2 = n; if (n2 < 0) goto L20; else if (n2 == 0) goto L10; --- 3276,3280 ---- i2 = MP.t + 5; ! n2 = *n; if (n2 < 0) goto L20; else if (n2 == 0) goto L10; *************** *** 3260,3264 **** L10: ! mpcim(1, &y[1]); return; --- 3284,3288 ---- L10: ! mpcim(&c__1, &y[1]); return; *************** *** 3266,3270 **** L20: ! mpchk(4, 10); n2 = -n2; if (x[1] != 0) goto L60; --- 3290,3294 ---- L20: ! mpchk(&c__4, &c__10); n2 = -n2; if (x[1] != 0) goto L60; *************** *** 3280,3284 **** L40: ! mpchk(2, 6); if (x[1] != 0) goto L60; --- 3304,3308 ---- L40: ! mpchk(&c__2, &c__6); if (x[1] != 0) goto L60; *************** *** 3296,3305 **** /* IF N .LT. 0 FORM RECIPROCAL */ ! if (n < 0) mprec(&y[1], &y[1]); mpstr(&y[1], &MP.r[i2 - 1]); /* SET PRODUCT TERM TO ONE */ ! mpcim(1, &y[1]); /* MAIN LOOP, LOOK AT BITS OF N2 FROM RIGHT */ --- 3320,3329 ---- /* IF N .LT. 0 FORM RECIPROCAL */ ! if (*n < 0) mprec(&y[1], &y[1]); mpstr(&y[1], &MP.r[i2 - 1]); /* SET PRODUCT TERM TO ONE */ ! mpcim(&c__1, &y[1]); /* MAIN LOOP, LOOK AT BITS OF N2 FROM RIGHT */ *************** *** 3317,3321 **** void ! mppwr2(const int *x, const int *y, int *z) { static int i2; --- 3341,3345 ---- void ! mppwr2(int *x, int *y, int *z) { static int i2; *************** *** 3332,3336 **** --x; ! mpchk(7, 16); if (x[1] < 0) goto L10; else if (x[1] == 0) goto L30; --- 3356,3360 ---- --x; ! mpchk(&c__7, &c__16); if (x[1] < 0) goto L10; else if (x[1] == 0) goto L30; *************** *** 3400,3404 **** /* CHECK LEGALITY OF B, T, M AND MXR */ ! mpchk(4, 10); /* MPADDI REQUIRES 2T+6 WORDS. */ --- 3424,3428 ---- /* CHECK LEGALITY OF B, T, M AND MXR */ ! mpchk(&c__4, &c__10); /* MPADDI REQUIRES 2T+6 WORDS. */ *************** *** 3431,3435 **** r__1 = (float)1. / rx; ! mpcrm(r__1, &MP.r[i2 - 1]); /* RESTORE EXPONENT */ --- 3455,3459 ---- r__1 = (float)1. / rx; ! mpcrm(&r__1, &MP.r[i2 - 1]); /* RESTORE EXPONENT */ *************** *** 3456,3460 **** L30: mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i3 - 1]); ! mpaddi(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]); /* TEMPORARILY REDUCE T */ --- 3480,3484 ---- L30: mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i3 - 1]); ! mpaddi(&MP.r[i3 - 1], &c_n1, &MP.r[i3 - 1]); /* TEMPORARILY REDUCE T */ *************** *** 3521,3525 **** static void ! mproot(int *x, int n, int *y) { --- 3545,3549 ---- static void ! mproot(int *x, int *n, int *y) { *************** *** 3545,3550 **** /* CHECK LEGALITY OF B, T, M AND MXR */ ! mpchk(4, 10); ! if (n != 1) goto L10; mpstr(&x[1], &y[1]); return; --- 3569,3574 ---- /* CHECK LEGALITY OF B, T, M AND MXR */ ! mpchk(&c__4, &c__10); ! if (*n != 1) goto L10; mpstr(&x[1], &y[1]); return; *************** *** 3553,3557 **** i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; ! if (n != 0) goto L30; if (v->MPerrors) { --- 3577,3581 ---- i2 = (MP.t << 1) + 7; i3 = i2 + MP.t + 2; ! if (*n != 0) goto L30; if (v->MPerrors) { *************** *** 3562,3566 **** L30: ! np = C_abs(n); /* LOSS OF ACCURACY IF NP LARGE, SO ONLY ALLOW NP .LE. MAX (B, 64) */ --- 3586,3590 ---- L30: ! np = C_abs(*n); /* LOSS OF ACCURACY IF NP LARGE, SO ONLY ALLOW NP .LE. MAX (B, 64) */ *************** *** 3588,3592 **** L70: y[1] = 0; ! if (n > 0) return; if (v->MPerrors) { --- 3612,3616 ---- L70: y[1] = 0; ! if (*n > 0) return; if (v->MPerrors) { *************** *** 3622,3626 **** r__1 = exp(((float) (np * ex - xes) * log((float) MP.b) - log((dabs(rx)))) / (float) np); ! mpcrm(r__1, &MP.r[i2 - 1]); /* SIGN OF APPROXIMATION SAME AS THAT OF X */ --- 3646,3650 ---- r__1 = exp(((float) (np * ex - xes) * log((float) MP.b) - log((dabs(rx)))) / (float) np); ! mpcrm(&r__1, &MP.r[i2 - 1]); /* SIGN OF APPROXIMATION SAME AS THAT OF X */ *************** *** 3656,3662 **** L120: ! mppwr(&MP.r[i2 - 1], np, &MP.r[i3 - 1]); mpmul(&x[1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mpaddi(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]); /* TEMPORARILY REDUCE T */ --- 3680,3686 ---- L120: ! mppwr(&MP.r[i2 - 1], &np, &MP.r[i3 - 1]); mpmul(&x[1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mpaddi(&MP.r[i3 - 1], &c_n1, &MP.r[i3 - 1]); /* TEMPORARILY REDUCE T */ *************** *** 3665,3669 **** MP.t = (MP.t + it0) / 2; mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mpdivi(&MP.r[i3 - 1], np, &MP.r[i3 - 1]); /* RESTORE T */ --- 3689,3693 ---- MP.t = (MP.t + it0) / 2; mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]); ! mpdivi(&MP.r[i3 - 1], &np, &MP.r[i3 - 1]); /* RESTORE T */ *************** *** 3711,3718 **** L160: MP.t = ts; ! if (n < 0) goto L170; ! i__1 = n - 1; ! mppwr(&MP.r[i2 - 1], i__1, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &y[1]); return; --- 3735,3742 ---- L160: MP.t = ts; ! if (*n < 0) goto L170; ! i__1 = *n - 1; ! mppwr(&MP.r[i2 - 1], &i__1, &MP.r[i2 - 1]); mpmul(&x[1], &MP.r[i2 - 1], &y[1]); return; *************** *** 3724,3728 **** void ! mpset(int idecpl, int itmax2, int maxdr) { int i__1; --- 3748,3752 ---- void ! mpset(int *idecpl, int *itmax2, int *maxdr) { int i__1; *************** *** 3753,3757 **** */ ! MP.mxr = maxdr; /* DETERMINE LARGE REPRESENTABLE INTEGER W OF FORM 2**K - 1 */ --- 3777,3781 ---- */ ! MP.mxr = *maxdr; /* DETERMINE LARGE REPRESENTABLE INTEGER W OF FORM 2**K - 1 */ *************** *** 3787,3791 **** L40: MP.m = w / 4; ! if (idecpl > 0) goto L60; if (v->MPerrors) { --- 3811,3815 ---- L40: MP.m = w / 4; ! if (*idecpl > 0) goto L60; if (v->MPerrors) { *************** *** 3800,3808 **** L60: i__1 = (k - 3) / 2; ! MP.b = mppow_ii(2, i__1); /* 2E0 BELOW ENSURES AT LEAST ONE GUARD DIGIT */ ! MP.t = (int) ((float) (idecpl) * log((float)10.) / log((float) MP.b) + (float) 2.0); --- 3824,3832 ---- L60: i__1 = (k - 3) / 2; ! MP.b = pow_ii(&c__2, &i__1); /* 2E0 BELOW ENSURES AT LEAST ONE GUARD DIGIT */ ! MP.t = (int) ((float) (*idecpl) * log((float)10.) / log((float) MP.b) + (float) 2.0); *************** *** 3810,3814 **** i2 = MP.t + 2; ! if (i2 <= itmax2) goto L80; if (v->MPerrors) { --- 3834,3838 ---- i2 = MP.t + 2; ! if (i2 <= *itmax2) goto L80; if (v->MPerrors) { *************** *** 3822,3836 **** /* REDUCE TO MAXIMUM ALLOWED BY DIMENSION STATEMENTS */ ! MP.t = itmax2 - 2; /* CHECK LEGALITY OF B, T, M AND MXR (AT LEAST T+4) */ L80: ! mpchk(1, 4); } void ! mpsin(const int *x, int *y) { float r__1; --- 3846,3860 ---- /* REDUCE TO MAXIMUM ALLOWED BY DIMENSION STATEMENTS */ ! MP.t = *itmax2 - 2; /* CHECK LEGALITY OF B, T, M AND MXR (AT LEAST T+4) */ L80: ! mpchk(&c__1, &c__4); } void ! mpsin(int *x, int *y) { float r__1; *************** *** 3849,3853 **** --x; ! mpchk(5, 12); i2 = (MP.t << 2) + 11; if (x[1] != 0) goto L20; --- 3873,3877 ---- --x; ! mpchk(&c__5, &c__12); i2 = (MP.t << 2) + 11; if (x[1] != 0) goto L20; *************** *** 3866,3872 **** /* USE MPSIN1 IF ABS(X) .LE. 1 */ ! if (mpcmpi(&MP.r[i2 - 1], 1) > 0) goto L30; ! mpsin1(&MP.r[i2 - 1], &y[1], 1); goto L50; --- 3890,3896 ---- /* USE MPSIN1 IF ABS(X) .LE. 1 */ ! if (mpcmpi(&MP.r[i2 - 1], &c__1) > 0) goto L30; ! mpsin1(&MP.r[i2 - 1], &y[1], &c__1); goto L50; *************** *** 3878,3902 **** L30: i3 = (MP.t << 1) + 7; ! mpart1(5, &MP.r[i3 - 1]); ! mpmuli(&MP.r[i3 - 1], 4, &MP.r[i3 - 1]); ! mpart1(239, &y[1]); mpsub(&MP.r[i3 - 1], &y[1], &y[1]); mpdiv(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpdivi(&MP.r[i2 - 1], 8, &MP.r[i2 - 1]); mpcmf(&MP.r[i2 - 1], &MP.r[i2 - 1]); /* SUBTRACT 1/2, SAVE SIGN AND TAKE ABS */ ! mpaddq(&MP.r[i2 - 1], -1, 2, &MP.r[i2 - 1]); xs = -xs * MP.r[i2 - 1]; if (xs == 0) goto L10; MP.r[i2 - 1] = 1; ! mpmuli(&MP.r[i2 - 1], 4, &MP.r[i2 - 1]); /* IF NOT LESS THAN 1, SUBTRACT FROM 2 */ if (MP.r[i2] > 0) { ! mpaddi(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]); } --- 3902,3926 ---- L30: i3 = (MP.t << 1) + 7; ! mpart1(&c__5, &MP.r[i3 - 1]); ! mpmuli(&MP.r[i3 - 1], &c__4, &MP.r[i3 - 1]); ! mpart1(&c__239, &y[1]); mpsub(&MP.r[i3 - 1], &y[1], &y[1]); mpdiv(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpdivi(&MP.r[i2 - 1], &c__8, &MP.r[i2 - 1]); mpcmf(&MP.r[i2 - 1], &MP.r[i2 - 1]); /* SUBTRACT 1/2, SAVE SIGN AND TAKE ABS */ ! mpaddq(&MP.r[i2 - 1], &c_n1, &c__2, &MP.r[i2 - 1]); xs = -xs * MP.r[i2 - 1]; if (xs == 0) goto L10; MP.r[i2 - 1] = 1; ! mpmuli(&MP.r[i2 - 1], &c__4, &MP.r[i2 - 1]); /* IF NOT LESS THAN 1, SUBTRACT FROM 2 */ if (MP.r[i2] > 0) { ! mpaddi(&MP.r[i2 - 1], &c_n2, &MP.r[i2 - 1]); } *************** *** 3904,3908 **** MP.r[i2 - 1] = 1; ! mpmuli(&MP.r[i2 - 1], 2, &MP.r[i2 - 1]); /* NOW REDUCED TO FIRST QUADRANT, IF LESS THAN PI/4 USE --- 3928,3932 ---- MP.r[i2 - 1] = 1; ! mpmuli(&MP.r[i2 - 1], &c__2, &MP.r[i2 - 1]); /* NOW REDUCED TO FIRST QUADRANT, IF LESS THAN PI/4 USE *************** *** 3913,3923 **** mpmul(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpsin1(&MP.r[i2 - 1], &y[1], 1); goto L50; L40: ! mpaddi(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]); mpmul(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpsin1(&MP.r[i2 - 1], &y[1], 0); L50: --- 3937,3947 ---- mpmul(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpsin1(&MP.r[i2 - 1], &y[1], &c__1); goto L50; L40: ! mpaddi(&MP.r[i2 - 1], &c_n2, &MP.r[i2 - 1]); mpmul(&MP.r[i2 - 1], &y[1], &MP.r[i2 - 1]); ! mpsin1(&MP.r[i2 - 1], &y[1], &c__0); L50: *************** *** 3947,3951 **** static void ! mpsin1(const int *x, int *y, int is) { int i__1; --- 3971,3975 ---- static void ! mpsin1(int *x, int *y, int *is) { int i__1; *************** *** 3968,3972 **** --x; ! mpchk(3, 8); if (x[1] != 0) goto L20; --- 3992,3996 ---- --x; ! mpchk(&c__3, &c__8); if (x[1] != 0) goto L20; *************** *** 3975,3979 **** L10: y[1] = 0; ! if (is == 0) mpcim(1, &y[1]); return; --- 3999,4003 ---- L10: y[1] = 0; ! if (*is == 0) mpcim(&c__1, &y[1]); return; *************** *** 3983,3987 **** b2 = max(MP.b,64) << 1; mpmul(&x[1], &x[1], &MP.r[i3 - 1]); ! if (mpcmpi(&MP.r[i3 - 1], 1) <= 0) goto L40; if (v->MPerrors) { --- 4007,4011 ---- b2 = max(MP.b,64) << 1; mpmul(&x[1], &x[1], &MP.r[i3 - 1]); ! if (mpcmpi(&MP.r[i3 - 1], &c__1) <= 0) goto L40; if (v->MPerrors) { *************** *** 3993,4003 **** L40: ! if (is == 0) mpcim(1, &MP.r[i2 - 1]); ! if (is != 0) mpstr(&x[1], &MP.r[i2 - 1]); y[1] = 0; i = 1; ts = MP.t; ! if (is == 0) goto L50; mpstr(&MP.r[i2 - 1], &y[1]); --- 4017,4027 ---- L40: ! if (*is == 0) mpcim(&c__1, &MP.r[i2 - 1]); ! if (*is != 0) mpstr(&x[1], &MP.r[i2 - 1]); y[1] = 0; i = 1; ts = MP.t; ! if (*is == 0) goto L50; mpstr(&MP.r[i2 - 1], &y[1]); *************** *** 4023,4049 **** i__1 = -i * (i + 1); ! mpdivi(&MP.r[i2 - 1], i__1, &MP.r[i2 - 1]); goto L70; L60: i__1 = -i; ! mpdivi(&MP.r[i2 - 1], i__1, &MP.r[i2 - 1]); i__1 = i + 1; ! mpdivi(&MP.r[i2 - 1], i__1, &MP.r[i2 - 1]); L70: i += 2; MP.t = ts; ! mpadd2(&MP.r[i2 - 1], &y[1], &y[1], y[1], 0); if (MP.r[i2 - 1] != 0) goto L50; L80: MP.t = ts; ! if (is == 0) mpaddi(&y[1], 1, &y[1]); } void ! mpsinh(const int *x, int *y) { int i__1; --- 4047,4073 ---- i__1 = -i * (i + 1); ! mpdivi(&MP.r[i2 - 1], &i__1, &MP.r[i2 - 1]); goto L70; L60: i__1 = -i; ! mpdivi(&MP.r[i2 - 1], &i__1, &MP.r[i2 - 1]); i__1 = i + 1; ! mpdivi(&MP.r[i2 - 1], &i__1, &MP.r[i2 - 1]); L70: i += 2; MP.t = ts; ! mpadd2(&MP.r[i2 - 1], &y[1], &y[1], &y[1], &c__0); if (MP.r[i2 - 1] != 0) goto L50; L80: MP.t = ts; ! if (*is == 0) mpaddi(&y[1], &c__1, &y[1]); } void ! mpsinh(int *x, int *y) { int i__1; *************** *** 4068,4072 **** L10: ! mpchk(5, 12); i3 = (MP.t << 2) + 11; --- 4092,4096 ---- L10: ! mpchk(&c__5, &c__12); i3 = (MP.t << 2) + 11; *************** *** 4097,4103 **** i2 = i3 - (MP.t + 2); mpexp1(&MP.r[i3 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], 2, &MP.r[i3 - 1]); mpmul(&MP.r[i3 - 1], &MP.r[i2 - 1], &y[1]); ! mpaddi(&MP.r[i2 - 1], 1, &MP.r[i3 - 1]); mpdiv(&y[1], &MP.r[i3 - 1], &y[1]); --- 4121,4127 ---- i2 = i3 - (MP.t + 2); mpexp1(&MP.r[i3 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], &c__2, &MP.r[i3 - 1]); mpmul(&MP.r[i3 - 1], &MP.r[i2 - 1], &y[1]); ! mpaddi(&MP.r[i2 - 1], &c__1, &MP.r[i3 - 1]); mpdiv(&y[1], &MP.r[i3 - 1], &y[1]); *************** *** 4106,4110 **** L30: i__1 = xs << 1; ! mpdivi(&y[1], i__1, &y[1]); } --- 4130,4134 ---- L30: i__1 = xs << 1; ! mpdivi(&y[1], &i__1, &y[1]); } *************** *** 4124,4128 **** --x; ! mpchk(4, 10); /* MPROOT NEEDS 4T+10 WORDS, BUT CAN OVERLAP SLIGHTLY. */ --- 4148,4152 ---- --x; ! mpchk(&c__4, &c__10); /* MPROOT NEEDS 4T+10 WORDS, BUT CAN OVERLAP SLIGHTLY. */ *************** *** 4145,4162 **** L40: ! mproot(&x[1], -2, &MP.r[i2 - 1]); i = MP.r[i2 + 1]; mpmul(&x[1], &MP.r[i2 - 1], &y[1]); iy3 = y[3]; ! mpext(i, iy3, &y[1]); } void ! mpstr(const int *x, int *y) { int i__1; ! static int i, t2; /* SETS Y = X FOR MP X AND Y. --- 4169,4186 ---- L40: ! mproot(&x[1], &c_n2, &MP.r[i2 - 1]); i = MP.r[i2 + 1]; mpmul(&x[1], &MP.r[i2 - 1], &y[1]); iy3 = y[3]; ! mpext(&i, &iy3, &y[1]); } void ! mpstr(int *x, int *y) { int i__1; ! static int i, j, t2; /* SETS Y = X FOR MP X AND Y. *************** *** 4167,4181 **** --x; /* HERE X(1) AND Y(1) MUST HAVE THE SAME ADDRESS */ ! if (y == x) return; /* HERE X(1) AND Y(1) HAVE DIFFERENT ADDRESSES */ ! y[1] = x[1]; /* NO NEED TO MOVE X(2), ... IF X(1) = 0 */ ! if (x[1] == 0) return; t2 = MP.t + 2; --- 4191,4211 ---- --x; + j = x[1]; + y[1] = j + 1; + if (j == x[1]) goto L10; /* HERE X(1) AND Y(1) MUST HAVE THE SAME ADDRESS */ ! ! x[1] = j; ! return; /* HERE X(1) AND Y(1) HAVE DIFFERENT ADDRESSES */ ! L10: ! y[1] = j; /* NO NEED TO MOVE X(2), ... IF X(1) = 0 */ ! if (j == 0) return; t2 = MP.t + 2; *************** *** 4186,4191 **** void ! mpsub(const int *x, const int *y, int *z) { /* SUBTRACTS Y FROM X, FORMING RESULT IN Z, FOR MP X, Y AND Z. --- 4216,4222 ---- void ! mpsub(int *x, int *y, int *z) { + static int y1[1]; /* SUBTRACTS Y FROM X, FORMING RESULT IN Z, FOR MP X, Y AND Z. *************** *** 4197,4206 **** --x; ! mpadd2(&x[1], &y[1], &z[1], -y[1], 0); } void ! mptanh(const int *x, int *y) { float r__1; --- 4228,4238 ---- --x; ! y1[0] = -y[1]; ! mpadd2(&x[1], &y[1], &z[1], y1, &c__0); } void ! mptanh(int *x, int *y) { float r__1; *************** *** 4225,4229 **** L10: ! mpchk(5, 12); i2 = (MP.t << 2) + 11; --- 4257,4261 ---- L10: ! mpchk(&c__5, &c__12); i2 = (MP.t << 2) + 11; *************** *** 4236,4245 **** r__1 = (float) MP.t * (float).5 * log((float) MP.b); ! mpcrm(r__1, &y[1]); if (mpcomp(&MP.r[i2 - 1], &y[1]) <= 0) goto L20; /* HERE ABS(X) IS VERY LARGE */ ! mpcim(xs, &y[1]); return; --- 4268,4277 ---- r__1 = (float) MP.t * (float).5 * log((float) MP.b); ! mpcrm(&r__1, &y[1]); if (mpcomp(&MP.r[i2 - 1], &y[1]) <= 0) goto L20; /* HERE ABS(X) IS VERY LARGE */ ! mpcim(&xs, &y[1]); return; *************** *** 4247,4251 **** L20: ! mpmuli(&MP.r[i2 - 1], 2, &MP.r[i2 - 1]); if (MP.r[i2] <= 0) goto L30; --- 4279,4283 ---- L20: ! mpmuli(&MP.r[i2 - 1], &c__2, &MP.r[i2 - 1]); if (MP.r[i2] <= 0) goto L30; *************** *** 4253,4258 **** mpexp(&MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], -1, &y[1]); ! mpaddi(&MP.r[i2 - 1], 1, &MP.r[i2 - 1]); mpdiv(&y[1], &MP.r[i2 - 1], &y[1]); goto L40; --- 4285,4290 ---- mpexp(&MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], &c_n1, &y[1]); ! mpaddi(&MP.r[i2 - 1], &c__1, &MP.r[i2 - 1]); mpdiv(&y[1], &MP.r[i2 - 1], &y[1]); goto L40; *************** *** 4262,4266 **** L30: mpexp1(&MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], 2, &y[1]); mpdiv(&MP.r[i2 - 1], &y[1], &y[1]); --- 4294,4298 ---- L30: mpexp1(&MP.r[i2 - 1], &MP.r[i2 - 1]); ! mpaddi(&MP.r[i2 - 1], &c__2, &y[1]); mpdiv(&MP.r[i2 - 1], &y[1], &y[1]); *************** *** 4283,4287 **** --x; /* Parameter adjustments */ ! mpchk(1, 4); /* THE UNDERFLOWING NUMBER IS SET TO ZERO --- 4315,4319 ---- --x; /* Parameter adjustments */ ! mpchk(&c__1, &c__4); /* THE UNDERFLOWING NUMBER IS SET TO ZERO *************** *** 4297,4301 **** static double ! mppow_di(double ap, int bp) { double pow, x; --- 4329,4333 ---- static double ! mppow_di(double *ap, int *bp) { double pow, x; *************** *** 4303,4308 **** pow = 1; ! x = ap; ! n = bp; if (n != 0) { --- 4335,4340 ---- pow = 1; ! x = *ap; ! n = *bp; if (n != 0) { *************** *** 4324,4334 **** static int ! mppow_ii(int ap, int bp) { int pow, x, n; pow = 1; ! x = ap; ! n = bp; if (n > 0) { --- 4356,4366 ---- static int ! pow_ii(int *ap, int *bp) { int pow, x, n; pow = 1; ! x = *ap; ! n = *bp; if (n > 0) { *************** *** 4345,4349 **** static double ! mppow_ri(float ap, int bp) { double pow, x; --- 4377,4381 ---- static double ! mppow_ri(float *ap, int *bp) { double pow, x; *************** *** 4351,4356 **** pow = 1; ! x = ap; ! n = bp; if (n != 0) { --- 4383,4388 ---- pow = 1; ! x = *ap; ! n = *bp; if (n != 0) { diff --context=2 ./mp.h /tmp/gcalctool-5.21.4/gcalctool/./mp.h *** ./mp.h 2008-01-14 01:13:25.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./mp.h 2007-12-17 16:37:50.000000000 +0100 *************** *** 26,64 **** void mperr(); ! int mpeq(const int *, const int *); ! int mpge(const int *, const int *); ! int mpgt(const int *, const int *); ! int mple(const int *, const int *); ! int mplt(const int *, const int *); ! void mpabs(const int *, int *); ! void mpadd(const int *, const int *, int *); ! void mpaddi(const int *, int, int *); ! void mpasin(const int *, int *); ! void mpatan(const int *, int *); ! void mpcdm(double, int *); ! void mpcim(int, int *); ! void mpcmd(const int *, double *); ! void mpcmf(const int *, int *); ! void mpcmi(const int *, int *); ! void mpcmim(const int *, int *); ! void mpcos(const int *, int *); ! void mpcosh(const int *, int *); ! void mpdiv(const int *, int *, int *); ! void mpdivi(const int *, int, int *); ! void mpexp(const int *, int *); ! void mpln(const int *, int *); ! void mpmul(const int *, const int *, int *); ! void mpmuli(const int *, int, int *); ! void mpneg(const int *, int *); void mppi(int *); ! void mppwr(const int *, int, int *); ! void mppwr2(const int *, const int *, int *); ! void mpset(int, int, int); ! void mpsin(const int *, int *); ! void mpsinh(const int *, int *); void mpsqrt(int *, int *); ! void mpstr(const int *, int *); ! void mpsub(const int *, const int *, int *); ! void mptanh(const int *, int *); #endif /* MP_H */ --- 26,64 ---- void mperr(); ! int mpeq(int *, int *); ! int mpge(int *, int *); ! int mpgt(int *, int *); ! int mple(int *, int *); ! int mplt(int *, int *); ! void mpabs(int *, int *); ! void mpadd(int *, int *, int *); ! void mpaddi(int *, int *, int *); ! void mpasin(int *, int *); ! void mpatan(int *, int *); ! void mpcdm(double *, int *); ! void mpcim(int *, int *); ! void mpcmd(int *, double *); ! void mpcmf(int *, int *); ! void mpcmi(int *, int *); ! void mpcmim(int *, int *); ! void mpcos(int *, int *); ! void mpcosh(int *, int *); ! void mpdiv(int *, int *, int *); ! void mpdivi(int *, int *, int *); ! void mpexp(int *, int *); ! void mpln(int *, int *); ! void mpmul(int *, int *, int *); ! void mpmuli(int *, int *, int *); ! void mpneg(int *, int *); void mppi(int *); ! void mppwr(int *, int *, int *); ! void mppwr2(int *, int *, int *); ! void mpset(int *, int *, int *); ! void mpsin(int *, int *); ! void mpsinh(int *, int *); void mpsqrt(int *, int *); ! void mpstr(int *, int *); ! void mpsub(int *, int *, int *); ! void mptanh(int *, int *); #endif /* MP_H */ diff --context=2 ./mpmath.c /tmp/gcalctool-5.21.4/gcalctool/./mpmath.c *** ./mpmath.c 2008-01-14 00:14:34.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./mpmath.c 2007-12-17 16:37:50.000000000 +0100 *************** *** 60,64 **** mpcmd(s2, &dval); dres = setbool(ibool(dres) & ibool(dval)); ! mpcdm(dres, t); } --- 60,64 ---- mpcmd(s2, &dval); dres = setbool(ibool(dres) & ibool(dval)); ! mpcdm(&dres, t); } *************** *** 72,76 **** mpcmd(s2, &dval); dres = setbool(ibool(dres) | ibool(dval)); ! mpcdm(dres, t); } --- 72,76 ---- mpcmd(s2, &dval); dres = setbool(ibool(dres) | ibool(dval)); ! mpcdm(&dres, t); } *************** *** 84,88 **** mpcmd(s2, &dval); dres = setbool(ibool(dres) ^ ibool(dval)); ! mpcdm(dres, t); } --- 84,88 ---- mpcmd(s2, &dval); dres = setbool(ibool(dres) ^ ibool(dval)); ! mpcdm(&dres, t); } *************** *** 96,100 **** mpcmd(s2, &dval); dres = setbool(~ibool(dres) ^ ibool(dval)); ! mpcdm(dres, t); } --- 96,100 ---- mpcmd(s2, &dval); dres = setbool(~ibool(dres) ^ ibool(dval)); ! mpcdm(&dres, t); } *************** *** 107,111 **** mpcmd(s1, &dval); dval = setbool(~ibool(dval)); ! mpcdm(dval, t); } --- 107,111 ---- mpcmd(s1, &dval); dval = setbool(~ibool(dval)); ! mpcdm(&dval, t); } *************** *** 116,120 **** double dval = drand48(); ! mpcdm(dval, t); } --- 116,120 ---- double dval = drand48(); ! mpcdm(&dval, t); } *************** *** 127,131 **** mpcmd(s1, &dval); dval = setbool(ibool(dval)); ! mpcdm(dval, t1); } --- 127,131 ---- mpcmd(s1, &dval); dval = setbool(ibool(dval)); ! mpcdm(&dval, t1); } *************** *** 138,152 **** mpcmd(s1, &dval); dval = setbool(ibool(dval) & 0xffff); ! mpcdm(dval, t1); } void ! calc_inv(const int s1[MP_SIZE], int t1[MP_SIZE]) /* Calculate 1/x */ { int MP1[MP_SIZE]; int MP2[MP_SIZE]; ! mpcim(1, MP1); mpstr(s1, MP2); mpdiv(MP1, MP2, t1); --- 138,153 ---- mpcmd(s1, &dval); dval = setbool(ibool(dval) & 0xffff); ! mpcdm(&dval, t1); } void ! calc_inv(int s1[MP_SIZE], int t1[MP_SIZE]) /* Calculate 1/x */ { int MP1[MP_SIZE]; int MP2[MP_SIZE]; + int i = 1; ! mpcim(&i, MP1); mpstr(s1, MP2); mpdiv(MP1, MP2, t1); *************** *** 155,163 **** void ! calc_tenpowx(const int s1[MP_SIZE], int t1[MP_SIZE]) /* Calculate 10^x */ { int MP1[MP_SIZE]; ! mpcim(10, MP1); mppwr2(MP1, s1, t1); } --- 156,165 ---- void ! calc_tenpowx(int s1[MP_SIZE], int t1[MP_SIZE]) /* Calculate 10^x */ { int MP1[MP_SIZE]; + int i = 10; ! mpcim(&i, MP1); mppwr2(MP1, s1, t1); } *************** *** 165,173 **** void ! calc_xpowy(const int MPx[MP_SIZE], const int MPy[MP_SIZE], int MPres[MP_SIZE]) /* Do x^y */ { ! int MP0[MP_SIZE]; ! do_zero(MP0); /* Check if both x and y are zero. If yes, then just return 1. --- 167,176 ---- void ! calc_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]) /* Do x^y */ { ! int MP0[MP_SIZE], val; ! val = 0; ! mpcim(&val, MP0); /* Check if both x and y are zero. If yes, then just return 1. *************** *** 175,179 **** */ if (mpeq(MPx, MP0) && mpeq(MPy, MP0)) { ! mpcim(1, MPres); } else if (mplt(MPx, MP0)) { /* Is x < 0 ? */ --- 178,183 ---- */ if (mpeq(MPx, MP0) && mpeq(MPy, MP0)) { ! val = 1; ! mpcim(&val, MPres); } else if (mplt(MPx, MP0)) { /* Is x < 0 ? */ *************** *** 185,189 **** mpcmi(MPy, &y); ! mppwr(MPx, y, MPres); } else { /* y != int(y). Force mppwr2 to generate an error. */ mppwr2(MPx, MPy, MPres); --- 189,193 ---- mpcmi(MPy, &y); ! mppwr(MPx, &y, MPres); } else { /* y != int(y). Force mppwr2 to generate an error. */ mppwr2(MPx, MPy, MPres); *************** *** 196,200 **** void ! calc_xtimestenpowx(const int s1[MP_SIZE], const int s2[MP_SIZE], int t1[MP_SIZE]) { int MP1[MP_SIZE]; --- 200,204 ---- void ! calc_xtimestenpowx(int s1[MP_SIZE], int s2[MP_SIZE], int t1[MP_SIZE]) { int MP1[MP_SIZE]; *************** *** 205,209 **** int ! calc_modulus(const int op1[MP_SIZE], int op2[MP_SIZE], int result[MP_SIZE]) --- 209,213 ---- int ! calc_modulus(int op1[MP_SIZE], int op2[MP_SIZE], int result[MP_SIZE]) *************** *** 223,227 **** void ! calc_percent(const int s1[MP_SIZE], int t1[MP_SIZE]) { int MP1[MP_SIZE]; --- 227,231 ---- void ! calc_percent(int s1[MP_SIZE], int t1[MP_SIZE]) { int MP1[MP_SIZE]; *************** *** 234,238 **** do_zero(int t1[MP_SIZE]) { ! mpcim(0, t1); } --- 238,244 ---- do_zero(int t1[MP_SIZE]) { ! int i = 0; ! ! mpcim(&i, t1); } *************** *** 243,247 **** double e = 2.71828182846; ! mpcdm(e, t1); } --- 249,253 ---- double e = 2.71828182846; ! mpcdm(&e, t1); } *************** *** 269,283 **** to_rad(int s1[MP_SIZE], int t1[MP_SIZE]) { ! int MP1[MP_SIZE], MP2[MP_SIZE]; if (v->ttype == DEG) { mppi(MP1); mpmul(s1, MP1, MP2); ! mpcim(180, MP1); mpdiv(MP2, MP1, t1); } else if (v->ttype == GRAD) { mppi(MP1); mpmul(s1, MP1, MP2); ! mpcim(200, MP1); mpdiv(MP2, MP1, t1); } else { --- 275,291 ---- to_rad(int s1[MP_SIZE], int t1[MP_SIZE]) { ! int i, MP1[MP_SIZE], MP2[MP_SIZE]; if (v->ttype == DEG) { mppi(MP1); mpmul(s1, MP1, MP2); ! i = 180; ! mpcim(&i, MP1); mpdiv(MP2, MP1, t1); } else if (v->ttype == GRAD) { mppi(MP1); mpmul(s1, MP1, MP2); ! i = 200; ! mpcim(&i, MP1); mpdiv(MP2, MP1, t1); } else { *************** *** 290,299 **** 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: ! mpcim(180, MP1); mpmul(s1, MP1, MP2); mppi(MP1); --- 298,308 ---- do_trig_typeconv(enum trig_type ttype, int s1[MP_SIZE], int t1[MP_SIZE]) { ! int i, MP1[MP_SIZE], MP2[MP_SIZE]; switch (ttype) { case DEG: ! i = 180; ! mpcim(&i, MP1); mpmul(s1, MP1, MP2); mppi(MP1); *************** *** 306,310 **** case GRAD: ! mpcim(200, MP1); mpmul(s1, MP1, MP2); mppi(MP1); --- 315,320 ---- case GRAD: ! i = 200; ! mpcim(&i, MP1); mpmul(s1, MP1, MP2); mppi(MP1); *************** *** 342,351 **** { int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; ! int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE]; mppi(MPpi); ! do_zero(MP0); ! mpcim(1, MP1); ! mpcim(-1, MPn1); if (mpgt(MPx, MP1) || mplt(MPx, MPn1)) { --- 352,364 ---- { int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; ! int MPn1[MP_SIZE], MPpi[MP_SIZE], MPy[MP_SIZE], val; mppi(MPpi); ! val = 0; ! mpcim(&val, MP0); ! val = 1; ! mpcim(&val, MP1); ! val = -1; ! mpcim(&val, MPn1); if (mpgt(MPx, MP1) || mplt(MPx, MPn1)) { *************** *** 353,357 **** mpstr(MP0, MPretval); } else if (mpeq(MPx, MP0)) { ! mpdivi(MPpi, 2, MPretval); } else if (mpeq(MPx, MP1)) { mpstr(MP0, MPretval); --- 366,371 ---- mpstr(MP0, MPretval); } else if (mpeq(MPx, MP0)) { ! val = 2; ! mpdivi(MPpi, &val, MPretval); } else if (mpeq(MPx, MP1)) { mpstr(MP0, MPretval); *************** *** 383,395 **** mpacosh(int *MPx, int *MPretval) { ! int MP1[MP_SIZE]; ! mpcim(1, MP1); if (mplt(MPx, MP1)) { doerr(_("Error")); ! do_zero(MPretval); } else { mpmul(MPx, MPx, MP1); ! mpaddi(MP1, -1, MP1); mpsqrt(MP1, MP1); mpadd(MPx, MP1, MP1); --- 397,412 ---- mpacosh(int *MPx, int *MPretval) { ! int MP1[MP_SIZE], val; ! val = 1; ! mpcim(&val, MP1); if (mplt(MPx, MP1)) { doerr(_("Error")); ! val = 0; ! mpcim(&val, MPretval); } else { mpmul(MPx, MPx, MP1); ! val = -1; ! mpaddi(MP1, &val, MP1); mpsqrt(MP1, MP1); mpadd(MPx, MP1, MP1); *************** *** 407,414 **** mpasinh(int *MPx, int *MPretval) { ! int MP1[MP_SIZE]; mpmul(MPx, MPx, MP1); ! mpaddi(MP1, 1, MP1); mpsqrt(MP1, MP1); mpadd(MPx, MP1, MP1); --- 424,432 ---- mpasinh(int *MPx, int *MPretval) { ! int MP1[MP_SIZE], val; mpmul(MPx, MPx, MP1); ! val = 1; ! mpaddi(MP1, &val, MP1); mpsqrt(MP1, MP1); mpadd(MPx, MP1, MP1); *************** *** 429,436 **** int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; int MP3[MP_SIZE], MPn1[MP_SIZE]; ! do_zero(MP0); ! mpcim(1, MP1); ! mpcim(-1, MPn1); if (mpge(MPx, MP1) || mple(MPx, MPn1)) { --- 447,458 ---- int MP0[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; int MP3[MP_SIZE], MPn1[MP_SIZE]; + int val; ! val = 0; ! mpcim(&val, MP0); ! val = 1; ! mpcim(&val, MP1); ! val = -1; ! mpcim(&val, MPn1); if (mpge(MPx, MP1) || mple(MPx, MPn1)) { *************** *** 456,462 **** mplog10(int *MPx, int *MPretval) { ! int MP1[MP_SIZE], MP2[MP_SIZE]; ! mpcim(10, MP1); mpln(MP1, MP1); mpln(MPx, MP2); --- 478,485 ---- mplog10(int *MPx, int *MPretval) { ! int MP1[MP_SIZE], MP2[MP_SIZE], n; ! n = 10; ! mpcim(&n, MP1); mpln(MP1, MP1); mpln(MPx, MP2); *************** *** 476,484 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpdiv(v->MPmvals[1], v->MPmvals[2], MP1); mpln(MP1, MP2); ! mpaddi(v->MPmvals[0], 1, MP3); mpln(MP3, MP4); mpdiv(MP2, MP4, t); --- 499,509 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpdiv(v->MPmvals[1], v->MPmvals[2], MP1); mpln(MP1, MP2); ! val = 1; ! mpaddi(v->MPmvals[0], &val, MP3); mpln(MP3, MP4); mpdiv(MP2, MP4, t); *************** *** 506,516 **** int i; int len; int MPbv[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; ! do_zero(MPbv); mpcmi(v->MPmvals[3], &len); for (i = 0; i < len; i++) { mpsub(v->MPmvals[0], MPbv, MP1); ! mpmuli(MP1, 2, MP2); mpdiv(MP2, v->MPmvals[2], t); mpstr(MPbv, MP1); --- 531,544 ---- int i; int len; + int val; int MPbv[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE]; ! i = 0; ! mpcim(&i, MPbv); mpcmi(v->MPmvals[3], &len); for (i = 0; i < len; i++) { mpsub(v->MPmvals[0], MPbv, MP1); ! val = 2; ! mpmuli(MP1, &val, MP2); mpdiv(MP2, v->MPmvals[2], t); mpstr(MPbv, MP1); *************** *** 531,539 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! mpaddi(v->MPmvals[1], 1, MP1); mppwr2(MP1, v->MPmvals[2], MP2); ! mpaddi(MP2, -1, MP3); mpmul(v->MPmvals[0], MP3, MP4); mpdiv(MP4, v->MPmvals[1], t); --- 559,570 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! val = 1; ! mpaddi(v->MPmvals[1], &val, MP1); mppwr2(MP1, v->MPmvals[2], MP2); ! val = -1; ! mpaddi(MP2, &val, MP3); mpmul(v->MPmvals[0], MP3, MP4); mpdiv(MP4, v->MPmvals[1], t); *************** *** 552,562 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! mpaddi(v->MPmvals[1], 1, MP1); ! mpmuli(v->MPmvals[2], -1, MP2); mppwr2(MP1, MP2, MP3); ! mpmuli(MP3, -1, MP4); ! mpaddi(MP4, 1, MP1); mpdiv(v->MPmvals[1], MP1, MP2); mpmul(v->MPmvals[0], MP2, t); --- 583,598 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! val = 1; ! mpaddi(v->MPmvals[1], &val, MP1); ! val = -1; ! mpmuli(v->MPmvals[2], &val, MP2); mppwr2(MP1, MP2, MP3); ! val = -1; ! mpmuli(MP3, &val, MP4); ! val = 1; ! mpaddi(MP4, &val, MP1); mpdiv(v->MPmvals[1], MP1, MP2); mpmul(v->MPmvals[0], MP2, t); *************** *** 575,585 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! mpaddi(v->MPmvals[1], 1, MP1); ! mpmuli(v->MPmvals[2], -1, MP2); mppwr2(MP1, MP2, MP3); ! mpmuli(MP3, -1, MP4); ! mpaddi(MP4, 1, MP1); mpdiv(MP1, v->MPmvals[1], MP2); mpmul(v->MPmvals[0], MP2, t); --- 611,626 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! val = 1; ! mpaddi(v->MPmvals[1], &val, MP1); ! val = -1; ! mpmuli(v->MPmvals[2], &val, MP2); mppwr2(MP1, MP2, MP3); ! val = -1; ! mpmuli(MP3, &val, MP4); ! val = 1; ! mpaddi(MP4, &val, MP1); mpdiv(MP1, v->MPmvals[1], MP2); mpmul(v->MPmvals[0], MP2, t); *************** *** 598,608 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpdiv(v->MPmvals[0], v->MPmvals[1], MP1); ! mpcim(1, MP2); mpdiv(MP2, v->MPmvals[2], MP3); mppwr2(MP1, MP3, MP4); ! mpaddi(MP4, -1, t); } --- 639,652 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpdiv(v->MPmvals[0], v->MPmvals[1], MP1); ! val = 1; ! mpcim(&val, MP2); mpdiv(MP2, v->MPmvals[2], MP3); mppwr2(MP1, MP3, MP4); ! val = -1; ! mpaddi(MP4, &val, t); } *************** *** 639,649 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpsub(v->MPmvals[2], v->MPmvals[3], MP2); ! mpaddi(MP2, 1, MP3); ! mpaddi(v->MPmvals[2], 1, MP2); mpmul(v->MPmvals[2], MP2, MP4); ! mpcim(2, MP2); mpdiv(MP4, MP2, MP1); mpdiv(MP3, MP1, MP2); --- 683,696 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; mpsub(v->MPmvals[2], v->MPmvals[3], MP2); ! val = 1; ! mpaddi(MP2, &val, MP3); ! mpaddi(v->MPmvals[2], &val, MP2); mpmul(v->MPmvals[2], MP2, MP4); ! val = 2; ! mpcim(&val, MP2); mpdiv(MP4, MP2, MP1); mpdiv(MP3, MP1, MP2); *************** *** 664,674 **** */ int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! mpaddi(v->MPmvals[2], 1, MP1); mpln(MP1, MP2); mpmul(v->MPmvals[1], v->MPmvals[2], MP1); mpdiv(MP1, v->MPmvals[0], MP3); ! mpaddi(MP3, 1, MP4); mpln(MP4, MP1); mpdiv(MP1, MP2, t); --- 711,724 ---- */ + int val; int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE]; ! val = 1; ! mpaddi(v->MPmvals[2], &val, MP1); mpln(MP1, MP2); mpmul(v->MPmvals[1], v->MPmvals[2], MP1); mpdiv(MP1, v->MPmvals[0], MP3); ! val = 1; ! mpaddi(MP3, &val, MP4); mpln(MP4, MP1); mpdiv(MP1, MP2, t); *************** *** 707,716 **** dval = setbool(temp); ! mpcdm(dval, t); } int ! is_integer(const int MPnum[MP_SIZE]) { int i = 10000; --- 757,766 ---- dval = setbool(temp); ! mpcdm(&dval, t); } int ! is_integer(int MPnum[MP_SIZE]) { int i = 10000; *************** *** 721,725 **** * mpcmim() routine in mp.c, when the exponent is less than 1. */ ! mpcim(i, MPtt); mpmul(MPnum, MPtt, MP0); mpdiv(MP0, MPtt, MP0); --- 771,775 ---- * mpcmim() routine in mp.c, when the exponent is less than 1. */ ! mpcim(&i, MPtt); mpmul(MPnum, MPtt, MP0); mpdiv(MP0, MPtt, MP0); *************** *** 731,735 **** int ! is_natural(const int MPnum[MP_SIZE]) { int MP1[MP_SIZE]; --- 781,785 ---- int ! is_natural(int MPnum[MP_SIZE]) { int MP1[MP_SIZE]; *************** *** 742,746 **** void ! calc_epowy(const int s[MP_SIZE], int t[MP_SIZE]) { int MP1[MP_SIZE]; --- 792,796 ---- void ! calc_epowy(int s[MP_SIZE], int t[MP_SIZE]) { int MP1[MP_SIZE]; diff --context=2 ./mpmath.h /tmp/gcalctool-5.21.4/gcalctool/./mpmath.h *** ./mpmath.h 2008-01-13 23:51:32.000000000 +0100 --- /tmp/gcalctool-5.21.4/gcalctool/./mpmath.h 2007-12-17 16:37:50.000000000 +0100 *************** *** 47,61 **** void calc_u32(int s1[MP_SIZE], int t1[MP_SIZE]); void calc_u16(int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_percent(const int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_inv(const int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_tenpowx(const int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_xpowy(const int MPx[MP_SIZE], const int MPy[MP_SIZE], ! int MPres[MP_SIZE]); void do_zero(int t1[MP_SIZE]); void do_e(int t1[MP_SIZE]); ! void calc_xtimestenpowx(const int s1[MP_SIZE], const int s2[MP_SIZE], ! int t1[MP_SIZE]); ! int calc_modulus(const int op1[MP_SIZE], int op2[MP_SIZE], ! int result[MP_SIZE]); void calc_ctrm(int t[MP_SIZE]); void calc_ddb(int t[MP_SIZE]); --- 47,58 ---- void calc_u32(int s1[MP_SIZE], int t1[MP_SIZE]); void calc_u16(int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_percent(int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_inv(int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_tenpowx(int s1[MP_SIZE], int t1[MP_SIZE]); ! void calc_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]); void do_zero(int t1[MP_SIZE]); void do_e(int t1[MP_SIZE]); ! void calc_xtimestenpowx(int s1[MP_SIZE], int s2[MP_SIZE], int t1[MP_SIZE]); ! int calc_modulus(int op1[MP_SIZE], int op2[MP_SIZE], int result[MP_SIZE]); void calc_ctrm(int t[MP_SIZE]); void calc_ddb(int t[MP_SIZE]); *************** *** 68,76 **** void calc_term(int t[MP_SIZE]); void calc_shift(int s[MP_SIZE], int t[MP_SIZE], int times); ! void calc_epowy(const int s[MP_SIZE], int t[MP_SIZE]); /* return true if parameter is integer */ int ! is_integer(const int MPnum[MP_SIZE]); /* return true if parameter is natural --- 65,73 ---- void calc_term(int t[MP_SIZE]); void calc_shift(int s[MP_SIZE], int t[MP_SIZE], int times); ! void calc_epowy(int s[MP_SIZE], int t[MP_SIZE]); /* return true if parameter is integer */ int ! is_integer(int MPnum[MP_SIZE]); /* return true if parameter is natural *************** *** 78,82 **** */ int ! is_natural(const int MPnum[MP_SIZE]); #endif /*MPMATH_H*/ --- 75,79 ---- */ int ! is_natural(int MPnum[MP_SIZE]); #endif /*MPMATH_H*/
Commits: http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2130 http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2131 http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2132 Last commit removes some gotos and parameter adjustments
More tidy ups: http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2162
Created attachment 116913 [details] [review] Sixth path from Klaus
More... http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2176
Removed the last of the parameter adjustments http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2177
Removed pointers... http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2177 And now i'm going to bed!
Created attachment 119342 [details] [review] Seventh patch from Klaus
Klaus' patch and some more goto removing: http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2231 http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2232 The gotos are now all essentially gone!
Refactored mp-convert.c and mp-trigonometric.c from mp.c/mpmath.c: http://svn.gnome.org/viewvc/gcalctool?view=revision&revision=2254 I'd like to see mp.c and mpmath.c split into more files and any gcalctool specific code removed. I've done a little of that in this patch. This change also highlights the global MP variable and mpchk() which should be removed asap for thread safety. (I don't get what this does; can anyone enlighten me?)
You should check out Prof. Richard Brent's original User Guide. I see he's moved now, so the address in the AUTHORS file is incorrect, but you can find it with the Wayback Machine: http://web.archive.org/web/20070205013619/http://web.comlab.ox.ac.uk/oucl/work/richard.brent/pd/rpb035.pdf For the MP struct, see page 4.
Closing as this is much cleaner now.