Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gcalctool/ChangeLog,v
retrieving revision 1.370
diff -u -r1.370 ChangeLog
--- ChangeLog	13 Sep 2005 21:38:54 -0000	1.370
+++ ChangeLog	15 Sep 2005 16:38:39 -0000
@@ -8,6 +8,14 @@
 gcalctool change history.
 =========================
 
+2005-09-15 Rich Burridge <rich.burridge@sun.com>
+
+    * Implemented enhancement request #148104 for non-arithmetic precedence
+      mode (http://bugzilla.gnome.org/show_bug.cgi?id=148104)
+      Added in a modulo operation. This is available in Scientic Mode.
+      A Mod B return the remainder when you divide A by B. A and B must be
+      integers. Keyboard shortcut for this operation is "M".
+
 2005-09-13 Rich Burridge <rich.burridge@sun.com>
 
     * Fixed bug #162453 (http://bugzilla.gnome.org/show_bug.cgi?id=162453)
Index: NEWS
===================================================================
RCS file: /cvs/gnome/gcalctool/NEWS,v
retrieving revision 1.220
diff -u -r1.220 NEWS
--- NEWS	13 Sep 2005 21:38:54 -0000	1.220
+++ NEWS	15 Sep 2005 16:38:39 -0000
@@ -5,6 +5,15 @@
  *  All Rights Reserved.
  */
 
+Overview of changes in gcalctool 5.7.3
+
+* Implemented enhancement request #148104 for non-arithmetic precedence
+  mode. Added in a modulo operation. This is available in Scientic Mode. 
+  A Mod B return the remainder when you divide A by B. A and B must be
+  integers. Keyboard shortcut for this operation is "M".
+
+----
+
 Overview of changes in gcalctool 5.7.2
 
 * Fixed bug #162453. The memory register dialog now uses GtkEntry widgets 
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gcalctool/configure.in,v
retrieving revision 1.335
diff -u -r1.335 configure.in
--- configure.in	13 Sep 2005 21:38:54 -0000	1.335
+++ configure.in	15 Sep 2005 16:38:39 -0000
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(gcalctool, 5.7.2)
+AM_INIT_AUTOMAKE(gcalctool, 5.7.3)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
Index: gcalctool/calctool.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.c,v
retrieving revision 1.94
diff -u -r1.94 calctool.c
--- gcalctool/calctool.c	19 Jul 2005 16:21:31 -0000	1.94
+++ gcalctool/calctool.c	15 Sep 2005 16:38:39 -0000
@@ -108,7 +108,7 @@
  *           |  a b c d e f g h i j k l m n o p q r s t u v w x y z
  *-----------+-----------------------------------------------------
  *  Lower:   |  a b c d e f     i     l m n   p   r s t u v   x
- *  Upper:   |  A   C D E F G     J K L   N   P   R S T       X Y
+ *  Upper:   |  A   C D E F G     J K L M N   P   R S T       X Y
  *  Numeric: |  0 1 2 3 4 5 6 7 8 9
  *  Other:   |  @ . + - * / = % ( ) # < > [ ] { } | & ~ ^ ? ! :
  *           |  BackSpace Delete Return
@@ -819,16 +819,16 @@
     none
 },
 {
-    "    ",
-    "    ",
+    N_("Mod"),
+    N_("Modulus Division"),
     NULL,
-    { 0, 0 },
-    { 0, 0 },
-    ' ',
+    { GDK_SHIFT_MASK, 0 },
+    { GDK_M,          0 },
+    'M',
     M_NONE,
-    do_none,
+    do_calc,
     NULL,
-    none
+    binop
 },
 {
     N_("Acc"),
Index: gcalctool/calctool.h
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.h,v
retrieving revision 1.73
diff -u -r1.73 calctool.h
--- gcalctool/calctool.h	22 Aug 2005 14:58:47 -0000	1.73
+++ gcalctool/calctool.h	15 Sep 2005 16:38:39 -0000
@@ -123,6 +123,7 @@
 #define KEY_RSFT  s_buttons[1]              /* > */
 #define KEY_16    s_buttons[2]              /* [ */
 #define KEY_32    s_buttons[3]              /* ] */
+#define KEY_MOD   s_buttons[6]              /* M */
 #define KEY_ACC   s_buttons[7]              /* A */
 
 #define KEY_CON   s_buttons[8]              /* # */
Index: gcalctool/functions.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/functions.c,v
retrieving revision 1.71
diff -u -r1.71 functions.c
--- gcalctool/functions.c	12 Sep 2005 16:58:10 -0000	1.71
+++ gcalctool/functions.c	15 Sep 2005 16:38:40 -0000
@@ -454,7 +454,7 @@
 do_calc()      /* Perform arithmetic calculation and display result. */
 {
     double dval, dres;
-    int MP1[MP_SIZE];
+    int MP1[MP_SIZE], MP2[MP_SIZE];
 
     if (!(v->opsptr && !v->show_paren)) {  /* Don't do if processing parens. */
         if (key_equal(v->current, KEY_EQ) && 
@@ -490,6 +490,18 @@
 
     } else if (IS_KEY(v->cur_op, KEY_DIV.value[0])) {     /* Division. */
         mpdiv(v->MPresult, v->MPdisp_val, v->MPresult);
+
+    } else if (IS_KEY(v->cur_op, KEY_MOD.value[0])) {     /* Modulus. */
+        mpcmim(v->MPresult, MP1);
+        mpcmim(v->MPdisp_val, MP2);
+        if (!mpeq(v->MPresult, MP1) || !mpeq(v->MPdisp_val, MP2)) {
+            doerr(_("Error, operands must be integers"));
+        }
+
+        mpdiv(v->MPresult, v->MPdisp_val, MP1);
+        mpcmim(MP1, MP1);
+        mpmul(MP1, v->MPdisp_val, MP2);
+        mpsub(v->MPresult, MP2, v->MPresult);
 
     } else if (IS_KEY(v->cur_op, KEY_PER.value[0])) {     /* % */
         mpmul(v->MPresult, v->MPdisp_val, v->MPresult);
