gcalctool r1912 - in trunk: . gcalctool
- From: richb svn gnome org
- To: svn-commits-list gnome org
- Subject: gcalctool r1912 - in trunk: . gcalctool
- Date: Thu, 24 Jan 2008 21:40:28 +0000 (GMT)
Author: richb
Date: Thu Jan 24 21:40:27 2008
New Revision: 1912
URL: http://svn.gnome.org/viewvc/gcalctool?rev=1912&view=rev
Log:
* gcalctool/ce_parser.y:
gcalctool/mpmath.c:
gcalctool/functions.c:
Fix for bug #511052 â Mod gives negative remainders.
Modified:
trunk/ChangeLog
trunk/gcalctool/ce_parser.y
trunk/gcalctool/functions.c
trunk/gcalctool/mpmath.c
Modified: trunk/gcalctool/ce_parser.y
==============================================================================
--- trunk/gcalctool/ce_parser.y (original)
+++ trunk/gcalctool/ce_parser.y Thu Jan 24 21:40:27 2008
@@ -148,13 +148,11 @@
exp:
term {cp($1, $$);}
-| '-' exp %prec NEG {mpneg($2, $$);}
-| '+' exp %prec POS {cp($2, $$);}
| exp '+' exp {mpadd($1, $3, $$);}
| exp '-' exp {mpsub($1, $3, $$);}
-| exp tMOD exp {
+| exp tMOD exp %prec MED {
if (!is_integer($1) || !is_integer($3)) {
parser_state.error = -PARSER_ERR_MODULUSOP;
} else {
Modified: trunk/gcalctool/functions.c
==============================================================================
--- trunk/gcalctool/functions.c (original)
+++ trunk/gcalctool/functions.c Thu Jan 24 21:40:27 2008
@@ -691,10 +691,19 @@
ui_set_statusbar(_("Error, operands must be integers"),
"gtk-dialog-error");
} else {
+ int val;
+
mpdiv(v->MPresult, v->MPdisp_val, MP1);
mpcmim(MP1, MP1);
mpmul(MP1, v->MPdisp_val, MP2);
mpsub(v->MPresult, MP2, v->MPresult);
+
+ val = 0;
+ mpcim(&val, MP1);
+ if ((mplt(v->MPdisp_val, MP1) && mpgt(v->MPresult, MP1)) ||
+ mplt(v->MPresult, MP1)) {
+ mpadd(v->MPresult, v->MPdisp_val, v->MPresult);
+ }
}
break;
Modified: trunk/gcalctool/mpmath.c
==============================================================================
--- trunk/gcalctool/mpmath.c (original)
+++ trunk/gcalctool/mpmath.c Thu Jan 24 21:40:27 2008
@@ -212,7 +212,7 @@
int op2[MP_SIZE],
int result[MP_SIZE])
{
- int MP1[MP_SIZE], MP2[MP_SIZE];
+ int MP1[MP_SIZE], MP2[MP_SIZE], val;
if (!is_integer(op1) || !is_integer(op2)) {
return -EINVAL;
@@ -222,6 +222,13 @@
mpcmim(MP1, MP1);
mpmul(MP1, op2, MP2);
mpsub(op1, MP2, result);
+
+ val = 0;
+ mpcim(&val, MP1);
+ if ((mplt(op2, MP1) && mpgt(result, MP1)) || mplt(result, MP1)) {
+ mpadd(result, op2, result);
+ }
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]