[gcalctool] Add variable word size, and 1's and 2's complement (Bug #581253)



commit 2f11771444311fe46ef93d6363be93a6e229c9fd
Author: Robin Sonefors <ozamosi flukkost nu>
Date:   Mon May 4 06:09:16 2009 +0200

    Add variable word size, and 1's and 2's complement (Bug #581253)
---
 ChangeLog                                       |    4 +
 data/gcalctool.schemas.in                       |   17 +++
 data/gcalctool.ui                               |  174 +++++++++++++++++------
 gcalctool/calctool.c                            |    5 +
 gcalctool/calctool.h                            |    1 +
 gcalctool/ce_parser.y                           |   26 +++-
 gcalctool/ce_tokeniser.l                        |    5 +-
 gcalctool/functions.c                           |   29 ++++-
 gcalctool/functions.h                           |    6 +-
 gcalctool/get.h                                 |    1 +
 gcalctool/gtk.c                                 |   66 ++++++++--
 gcalctool/mp-binary.c                           |   81 +++++++----
 gcalctool/mp.h                                  |    7 +-
 gcalctool/parser.h                              |    1 +
 gcalctool/ui.h                                  |    1 +
 help/C/figures/gcalctool_programming_window.png |  Bin 10244 -> 12077 bytes
 help/C/gcalctool.xml                            |  127 +++++++++++++----
 help/ChangeLog                                  |    5 +
 18 files changed, 430 insertions(+), 126 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 08faab5..47d9556 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
 gcalctool change history.
 =========================
 
+2009-05-07 Robin Sonefors <ozamosi flukkost nu>
+
+    * Add 1's and 2's complement to programming mode (Robin Sonefors, Bug #581253)
+    * Add variable word size for bitwise functions (Robin Sonefors, Bug #581253)
 2009-05-07 Robert Ancell <robert ancell gmail com>
 
     * Add a --solve command-line argument (Robert Ancell)
diff --git a/data/gcalctool.schemas.in b/data/gcalctool.schemas.in
index e1c8d9e..b31dfde 100644
--- a/data/gcalctool.schemas.in
+++ b/data/gcalctool.schemas.in
@@ -75,6 +75,7 @@ To change the gconftool target use the - -config-source=blah option to gconftool
             FINANCIAL
             LOGICAL 
             SCIENTIFIC
+            PROGRAMMING
         </long>
       </locale>
     </schema>
@@ -135,6 +136,22 @@ To change the gconftool target use the - -config-source=blah option to gconftool
         </long>
       </locale>
     </schema>
+    <schema>
+      <applyto>/apps/gcalctool/wordlen</applyto>
+      <key>/schemas/apps/gcalctool/wordlen</key>
+      <owner>gcalctool</owner>
+      <type>int</type>
+      <default>64</default>
+      <locale name="C">
+        <short>Word size</short>
+        <long>
+          The size of the words used in bitwise operations. Valid values are
+            16
+            32
+            64.
+        </long>
+      </locale>
+    </schema>
     <schema> 
       <applyto>/apps/gcalctool/xposition</applyto>
       <key>/schemas/apps/gcalctool/xposition</key> 
diff --git a/data/gcalctool.ui b/data/gcalctool.ui
index d5d5d14..c38d2df 100644
--- a/data/gcalctool.ui
+++ b/data/gcalctool.ui
@@ -330,6 +330,64 @@
           <object class="GtkHBox" id="programming_mode_panel">
             <property name="visible">True</property>
             <child>
+              <object class="GtkHBox" id="hbox7">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkRadioButton" id="64bit_radio">
+                    <property name="label" translatable="yes" comments="64 bit radio button">_64 bit</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Makes the bitwise functions use 64 bit mode</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                    <signal name="toggled" handler="word_cb"/>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="32bit_radio">
+                    <property name="label" translatable="yes" comments="32 bit radio button">_32 bit</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Makes the bitwise functions use 32 bit mode</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">64bit_radio</property>
+                    <signal name="toggled" handler="word_cb"/>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkRadioButton" id="16bit_radio">
+                    <property name="label" translatable="yes" comments="16 bit radio button">_16 bit</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip_text" translatable="yes">Makes the bitwise functions use 16 bit mode</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">64bit_radio</property>
+                    <signal name="toggled" handler="word_cb"/>
+                  </object>
+                  <packing>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="pack_type">start</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkHBox" id="hbox6">
                 <property name="visible">True</property>
                 <child>
@@ -3042,7 +3100,7 @@
           <object class="GtkTable" id="programming_panel">
             <property name="visible">True</property>
             <property name="border_width">6</property>
-            <property name="n_rows">2</property>
+            <property name="n_rows">3</property>
             <property name="n_columns">8</property>
             <property name="column_spacing">6</property>
             <property name="row_spacing">6</property>
@@ -3059,6 +3117,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3077,6 +3137,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3093,6 +3155,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -3111,8 +3175,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3131,8 +3195,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3151,8 +3215,42 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="calc_1s_button">
+                <property name="label" translatable="yes" comments="1's complement">1's</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">1's complement [z]</property>
+                <property name="use_underline">True</property>
+                <property name="focus_on_click">False</property>
+                <signal name="clicked" handler="button_cb"/>
+              </object>
+              <packing>
+                <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="calc_2s_button">
+                <property name="label" translatable="yes" comments="2's complement">2's</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="tooltip_text" translatable="yes">2's complement [Z]</property>
+                <property name="use_underline">True</property>
+                <property name="focus_on_click">False</property>
+                <signal name="clicked" handler="button_cb"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3169,8 +3267,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">6</property>
-                <property name="right_attach">7</property>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -3189,8 +3287,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">7</property>
-                <property name="right_attach">8</property>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -3198,21 +3296,21 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="calc_mask_32_button">
-                <property name="label" translatable="yes" comments="32 bit unsigned integer">&amp;32</property>
+              <object class="GtkButton" id="calc_trunc_button">
+                <property name="label" translatable="yes" comments="Truncate displayed value">Trunc</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">32-bit unsigned integer value of display ([)</property>
+                <property name="tooltip_text" translatable="yes">Truncate displayed value to the chosen word size ([)</property>
                 <property name="use_underline">True</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">4</property>
-                <property name="right_attach">5</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="top_attach">0</property>
+                <property name="bottom_attach">1</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3229,8 +3327,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">7</property>
-                <property name="right_attach">8</property>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3247,8 +3345,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -3267,8 +3365,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3285,28 +3383,8 @@
                 <signal name="clicked" handler="button_cb"/>
               </object>
               <packing>
-                <property name="left_attach">6</property>
-                <property name="right_attach">7</property>
-                <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="calc_mask_16_button">
-                <property name="label" translatable="yes" comments="16 bit unsigned integer">&amp;16</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">16-bit unsigned integer value of display (])</property>
-                <property name="use_underline">True</property>
-                <property name="focus_on_click">False</property>
-                <signal name="clicked" handler="button_cb"/>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="right_attach">4</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3349,6 +3427,8 @@
               <packing>
                 <property name="left_attach">3</property>
                 <property name="right_attach">4</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -3391,6 +3471,8 @@
               <packing>
                 <property name="left_attach">4</property>
                 <property name="right_attach">5</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
diff --git a/gcalctool/calctool.c b/gcalctool/calctool.c
index 3f19346..c313772 100644
--- a/gcalctool/calctool.c
+++ b/gcalctool/calctool.c
@@ -279,6 +279,11 @@ init_state(void)
        v->ttype = (TrigType) i;
     else
        v->ttype = DEG;  
+
+    if (get_int_resource(R_WORDLEN, &i))
+       v->wordlen = i;
+    else
+       v->wordlen = 64;
 }
 
 
diff --git a/gcalctool/calctool.h b/gcalctool/calctool.h
index 0aebdbe..5240f51 100644
--- a/gcalctool/calctool.h
+++ b/gcalctool/calctool.h
@@ -76,6 +76,7 @@ typedef struct {
 
     BaseType base;            /* Numeric base (BIN, OCT, DEC or HEX). */
     TrigType ttype;           /* Trigonometric type (DEG, GRAD or RAD). */
+    int wordlen;              /* Length of word for bitwise operations */
     int accuracy;             /* Number of digits precision. */
 
     int error;                /* true if there is a display error */
diff --git a/gcalctool/ce_parser.y b/gcalctool/ce_parser.y
index e1db1c7..1e41c18 100644
--- a/gcalctool/ce_parser.y
+++ b/gcalctool/ce_parser.y
@@ -59,6 +59,8 @@
 %token tLOG10
 %token tLOG2
 %token tMOD
+%token t1S
+%token t2S
 %token tNOT
 %token tOR
 %token tPI
@@ -70,8 +72,7 @@
 %token tSTO
 %token tTAN
 %token tTANH
-%token tU16
-%token tU32
+%token tTRUNC
 %token tXNOR
 %token tXOR
 
@@ -188,6 +189,8 @@ term:
 | '~' term %prec LNEG {
     if (!mp_is_natural(&$2)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
+    } else if (!mp_is_overflow(&$2)) {
+	parser_state.error = -PARSER_ERR_OVERFLOW;
     }
     mp_not(&$2, &$$);
 }
@@ -233,8 +236,23 @@ func:
 | tACOSH term %prec HIGH {mp_acosh(&$2, &$$);}
 | tATANH term %prec HIGH {mp_atanh(&$2, &$$);}
 
-| tU32 term %prec HIGH {mp_mask_u32(&$2, &$$);}
-| tU16 term %prec HIGH {mp_mask_u16(&$2, &$$);}
+| tTRUNC term %prec HIGH {mp_mask(&$2, &$$);}
+| t1S term %prec HIGH  {
+    if (!mp_is_natural(&$2)) {
+	parser_state.error = -PARSER_ERR_BITWISEOP;
+    } else if (!mp_is_overflow(&$2)) {
+	parser_state.error = -PARSER_ERR_OVERFLOW;
+    }
+    mp_1s_complement(&$2, &$$);
+}
+| t2S term %prec HIGH {
+    if (!mp_is_natural(&$2)) {
+	parser_state.error = -PARSER_ERR_BITWISEOP;
+    } else if (!mp_is_overflow(&$2)) {
+	parser_state.error = -PARSER_ERR_OVERFLOW;
+    }
+    mp_2s_complement(&$2, &$$);
+}
 ;
 
 rcl:
diff --git a/gcalctool/ce_tokeniser.l b/gcalctool/ce_tokeniser.l
index a534d5e..5cdd237 100644
--- a/gcalctool/ce_tokeniser.l
+++ b/gcalctool/ce_tokeniser.l
@@ -84,8 +84,9 @@ BIN_NUM{BIN}+|{BIN}*{DECIMAL}{BIN}*
 "sto"|"Sto"|"STO" {return tSTO;}
 "tanh"|"Tanh"|"TANH" {return tTANH;}
 "tan"|"Tan"|"TAN" {return tTAN;}
-"u16"|"u16"|"U16" {return tU16;}
-"u32"|"u32"|"U32" {return tU32;}
+"trunc"|"Trunc"|"TRUNC" {return tTRUNC;}
+"1s"|"1S" {return t1S;}
+"2s"|"2S" {return t2S;}
 "xnor"|"Xnor"|"XNOR" {return tXNOR;}
 "xor"|"Xor"|"XOR" {return tXOR;}
 
diff --git a/gcalctool/functions.c b/gcalctool/functions.c
index 0e65b8c..01e39cd 100644
--- a/gcalctool/functions.c
+++ b/gcalctool/functions.c
@@ -110,9 +110,10 @@ static Function functions[NFUNCTIONS] = {
 { FN_LOGARITHM,         "Log", FUNC },
 { FN_LOGARITHM2,        "Log2", FUNC },
 { FN_ABSOLUTE_VALUE,    "Abs", FUNC },
-{ FN_MASK_16,           "u16", FUNC },            
-{ FN_MASK_32,           "u32", FUNC },
+{ FN_TRUNC,             "Trunc", FUNC },
 { FN_MODULUS_DIVIDE,    " Mod ", 0 },
+{ FN_1S_COMPLEMENT,     "1s", FUNC },
+{ FN_2S_COMPLEMENT,     "2s", FUNC },
 { FN_EXPONENTIAL,       "e", 0 },
 { FN_NOT,               "~", 0 },
 { FN_OR,                " OR ", 0 },
@@ -138,6 +139,7 @@ static Function functions[NFUNCTIONS] = {
 { FN_SET_BASE,          NULL, 0 },
 { FN_SET_NUMBERTYPE,    NULL, 0 },
 { FN_SET_TRIG_TYPE,     NULL, 0 },
+{ FN_SET_WORDLEN,       NULL, 0 },
 { FN_UNDO,              NULL, 0 },
 { FN_REDO,              NULL, 0 },
 { FN_CONSTANT,          NULL, 0 },
@@ -324,6 +326,16 @@ do_exchange(int index)
 }
 
 
+/* Set word size for bitwise operations. */
+static void
+do_wordlen(int len)
+{
+    mp_set_wordlen(len);
+    v->wordlen = len;
+    set_int_resource(R_WORDLEN, len);
+}
+
+
 static void
 do_numtype(DisplayFormat n)   /* Set number display type. */
 {
@@ -426,7 +438,11 @@ do_expression(int function, int arg, int cursor)
 
         case FN_SET_NUMBERTYPE:
             do_numtype(arg);
-            return;        
+            return;
+
+        case FN_SET_WORDLEN:
+            do_wordlen(arg);
+            return;
         
         case FN_FUNCTION:
             do_function(arg);
@@ -538,6 +554,13 @@ do_expression(int function, int arg, int cursor)
                         message = _("Invalid modulus operation");
                         break;
 
+                    case -PARSER_ERR_OVERFLOW:
+                        /* Translators; Error displayd to user when they
+                         * perform a bitwise operation on numbers greater
+                         * than the current word */
+                       message = _("Overflow. Try a bigger word size");
+                       break;
+
                     case -MPMATH_ERR:
                         message = v->math_error_text;
                         break;
diff --git a/gcalctool/functions.h b/gcalctool/functions.h
index 49f545e..8cb4f42 100644
--- a/gcalctool/functions.h
+++ b/gcalctool/functions.h
@@ -59,9 +59,10 @@ enum
     FN_LOGARITHM,
     FN_LOGARITHM2,
     FN_ABSOLUTE_VALUE,
-    FN_MASK_16,
-    FN_MASK_32,
+    FN_TRUNC,
     FN_MODULUS_DIVIDE,
+    FN_1S_COMPLEMENT,
+    FN_2S_COMPLEMENT,
     FN_EXPONENTIAL,
     FN_NOT, FN_OR, FN_AND, FN_XOR, FN_XNOR,
     FN_TOGGLE_BIT,
@@ -81,6 +82,7 @@ enum
     FN_SET_BASE,
     FN_SET_NUMBERTYPE,
     FN_SET_TRIG_TYPE,
+    FN_SET_WORDLEN,
     FN_UNDO,
     FN_REDO,
     FN_CONSTANT,
diff --git a/gcalctool/get.h b/gcalctool/get.h
index d1adc0b..807ae24 100644
--- a/gcalctool/get.h
+++ b/gcalctool/get.h
@@ -32,6 +32,7 @@
 #define R_TRIG     "trigtype"
 #define R_ZEROES   "showzeroes"
 #define R_TSEP     "showthousands"
+#define R_WORDLEN  "wordlen"
 #define R_XPOS     "xposition"
 #define R_YPOS     "yposition"
 
diff --git a/gcalctool/gtk.c b/gcalctool/gtk.c
index e2738d4..7635b3e 100644
--- a/gcalctool/gtk.c
+++ b/gcalctool/gtk.c
@@ -100,10 +100,10 @@ static char *finc_dialog_fields[FINC_NUM_DIALOGS][5] = {
  *
  *           |  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 g h i j k l m n o p q r s t u v   x
- *  Upper:   |  A   C D E F G H I J K   M N O P Q R S T       X Y
+ *  Lower:   |  a b c d e f g h i j k l m n o p q r s t u v w x   z
+ *  Upper:   |  A   C D E F G H I J K   M N O P Q R S T     W X Y Z
  *  Numeric: |  0 1 2 3 4 5 6 7 8 9
- *  Other:   |  @ . + - * / = % ( ) # < > [ ] { | & ~ ^ ? ! :
+ *  Other:   |  @ . + - * / = % ( ) # < > [   { | & ~ ^ ? ! :
  *           |  BackSpace Delete Return
  *-----------+-----------------------------------------------------
  */
@@ -297,18 +297,22 @@ static struct button_widget button_widgets[] = {
     { 0,     0 },
     { GDK_u, 0 }},
 
-    {FN_MASK_16,            "mask_16",
+    {FN_TRUNC,              "trunc",
     { 0,                0 },
-    { GDK_bracketright, 0 }},
-
-    {FN_MASK_32,            "mask_32",
-    { 0,               0 },
     { GDK_bracketleft, 0 }},
 
     {FN_MODULUS_DIVIDE,     "modulus_divide",
     { 0,     0 },
     { GDK_M, 0 }},
 
+    {FN_1S_COMPLEMENT,      "1s",
+    { 0,     0 },
+    { GDK_z, 0 }},
+
+    {FN_2S_COMPLEMENT,      "2s",
+    { 0,     0 },
+    { GDK_Z, 0 }},
+
     {FN_EXPONENTIAL,        "exponential",
     { 0,     0 },
     { GDK_E, 0 }},
@@ -508,10 +512,13 @@ typedef struct {
     /* Scientific mode widgets */
     GtkWidget *hyperbolic_toggle;      /* Hyperbolic mode. */
     GtkWidget *inverse_toggle;         /* Inverse mode. */
-    GtkWidget *base[MAXBASES];         /* Numeric base radio buttons. */
     GtkWidget *disp[MAXDISPMODES];     /* Numeric display mode. */
     GtkWidget *trig[MAXTRIGMODES];     /* Trigonometric mode. */
 
+    /* Programming mode widgets */
+    GtkWidget *base[MAXBASES];         /* Numeric base radio buttons. */
+    GtkWidget *wordlen[3];             /* Wordlength radio buttons. */
+
     char *shelf;                       /* PUT selection shelf contents. */   
 } GtkUI;
 static GtkUI X;
@@ -1152,6 +1159,24 @@ ui_set_base(BaseType base)
 
 
 void
+ui_set_wordlen(int len)
+{
+    v->wordlen = len;
+    switch (len) {
+        case 64:
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(X.wordlen[0]), 1);
+            break;
+        case 32:
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(X.wordlen[1]), 1);
+            break;
+        case 16:
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(X.wordlen[2]), 1);
+            break;
+    }
+}
+
+
+void
 ui_set_registers_visible(gboolean visible)
 {
     GtkWidget *menu;
@@ -1358,6 +1383,17 @@ base_cb(GtkWidget *widget)
     }
 }
 
+G_MODULE_EXPORT
+void
+word_cb(GtkWidget *widget)
+{
+    int wordlen;
+
+    wordlen = (int) g_object_get_data(G_OBJECT(widget), "wordlen_mode");
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        do_button(FN_SET_WORDLEN, wordlen);
+    }
+}
 
 static void
 help_display(void)
@@ -2429,6 +2465,9 @@ create_kframe()
     X.disp[0]      = GET_WIDGET("engineering_radio");
     X.disp[1]      = GET_WIDGET("fixed_point_radio");
     X.disp[2]      = GET_WIDGET("scientific_radio");
+    X.wordlen[0]   = GET_WIDGET("64bit_radio");
+    X.wordlen[1]   = GET_WIDGET("32bit_radio");
+    X.wordlen[2]   = GET_WIDGET("16bit_radio");
     X.inverse_toggle    = GET_WIDGET("inverse_check");
     X.hyperbolic_toggle = GET_WIDGET("hyperbolic_check");
     X.statusbar    = GET_WIDGET("statusbar");
@@ -2609,6 +2648,13 @@ create_kframe()
     for (i = 0; i < 3; i++)        
         g_object_set_data(G_OBJECT(X.disp[i]),
                           "numeric_mode", GINT_TO_POINTER(i));
+    
+    g_object_set_data(G_OBJECT(X.wordlen[0]),
+                          "wordlen_mode", GINT_TO_POINTER(64));
+    g_object_set_data(G_OBJECT(X.wordlen[1]),
+                          "wordlen_mode", GINT_TO_POINTER(32));
+    g_object_set_data(G_OBJECT(X.wordlen[2]),
+                          "wordlen_mode", GINT_TO_POINTER(16));
 
     X.status_image = GET_WIDGET("status_image");
 
@@ -2712,6 +2758,7 @@ ui_load(void)
     ui_set_mode(X.mode);
     ui_set_numeric_mode(v->display.format);
     ui_set_base(v->base);
+    ui_set_wordlen(v->wordlen);
     ui_set_accuracy(v->accuracy);
     ui_set_undo_enabled(FALSE, FALSE);
     ui_update_modifier_mode();
@@ -2732,6 +2779,7 @@ void
 ui_start(void)
 {
     ui_set_base(v->base);
+    ui_set_wordlen(v->wordlen);
     ui_set_trigonometric_mode(v->ttype);
     ui_set_numeric_mode(v->display.format);
 
diff --git a/gcalctool/mp-binary.c b/gcalctool/mp-binary.c
index 80fae20..6aacb24 100644
--- a/gcalctool/mp-binary.c
+++ b/gcalctool/mp-binary.c
@@ -2,6 +2,7 @@
 #include "calctool.h" // FIXME
 
 static char digits[] = "0123456789ABCDEF";
+static int current_wordlen = 64;
 
 static int hex_to_int(char digit)
 {
@@ -16,7 +17,7 @@ static int hex_to_int(char digit)
 
 
 static void
-mp_bitwise(const MPNumber *s1, const MPNumber *s2, int (*bitwise_operator)(int, int), MPNumber *t)
+mp_bitwise(const MPNumber *s1, const MPNumber *s2, int (*bitwise_operator)(int, int), MPNumber *t, int wordlen)
 {
     char text1[MAX_DIGITS], text2[MAX_DIGITS], text_out[MAX_DIGITS];
     int offset1, offset2, offset_out;
@@ -25,12 +26,15 @@ mp_bitwise(const MPNumber *s1, const MPNumber *s2, int (*bitwise_operator)(int,
     mp_cast_to_string(text2, MAX_DIGITS, s2, 16, 0);
     offset1 = strlen(text1) - 1;
     offset2 = strlen(text2) - 1;
-    offset_out = offset1 > offset2 ? offset1 : offset2;
+    offset_out = wordlen / 4 - 1;
+    if (offset_out <= 0) {
+        offset_out = offset1 > offset2 ? offset1 : offset2;
+    }
+    if (offset_out > 0 && (offset_out < offset1 || offset_out < offset2)) {
+        mperr("Overflow. Try a bigger word size");
+        return;
+    }
    
-    /* Be at least 32 bits wide so inverse operations make sense */
-    if (offset_out < 7)
-        offset_out = 7;
-
     /* Perform bitwise operator on each character from right to left */
     for (text_out[offset_out+1] = '\0'; offset_out >= 0; offset_out--) {
         int v1 = 0, v2 = 0;
@@ -57,31 +61,48 @@ static int mp_bitwise_xnor(int v1, int v2) { return v1 ^ v2 ^ 0xF; }
 static int mp_bitwise_not(int v1, int dummy) { return v1 ^ 0xF; }
 
 
+int
+mp_is_overflow (const MPNumber *s1)
+{
+    MPNumber tmp1, tmp2;
+    mp_set_from_integer(2, &tmp1);
+    mppwr(&tmp1, current_wordlen, &tmp2);
+    return mp_is_greater_than (&tmp2, s1);
+}
+
+
+void
+mp_set_wordlen (int len)
+{
+    current_wordlen = len;
+}
+
+
 void
 mp_and(const MPNumber *s1, const MPNumber *s2, MPNumber *t)
 {
-    mp_bitwise(s1, s2, mp_bitwise_and, t);
+    mp_bitwise(s1, s2, mp_bitwise_and, t, 0);
 }
 
 
 void
 mp_or(const MPNumber *s1, const MPNumber *s2, MPNumber *t)
 {
-    mp_bitwise(s1, s2, mp_bitwise_or, t);
+    mp_bitwise(s1, s2, mp_bitwise_or, t, 0);
 }
 
 
 void
 mp_xor(const MPNumber *s1, const MPNumber *s2, MPNumber *t)
 {
-    mp_bitwise(s1, s2, mp_bitwise_xor, t);
+    mp_bitwise(s1, s2, mp_bitwise_xor, t, 0);
 }
 
 
 void
 mp_xnor(const MPNumber *s1, const MPNumber *s2, MPNumber *t)
 {
-    mp_bitwise(s1, s2, mp_bitwise_xnor, t);
+    mp_bitwise(s1, s2, mp_bitwise_xnor, t, 0);
 }
 
 
@@ -90,34 +111,21 @@ mp_not(const MPNumber *s1, MPNumber *t)
 {
     MPNumber temp;
     mp_set_from_integer(0, &temp);
-    mp_bitwise(s1, &temp, mp_bitwise_not, t);
+    mp_bitwise(s1, &temp, mp_bitwise_not, t, current_wordlen);
 }
 
 
 void
-mp_mask_u32(const MPNumber *s1, MPNumber *t1)
+mp_mask(const MPNumber *s1, MPNumber *t1)
 {
     char text[MAX_DIGITS];
     size_t len, offset;
     
-    /* Convert to a hexadecimal string and use last 8 characters */
+    /* Convert to a hexadecimal string and use last characters */
     mp_cast_to_string(text, MAX_DIGITS, s1, 16, 0);
     len = strlen(text);
-    offset = len > 8 ? len - 8: 0;
-    mp_set_from_string(text + offset, 16, t1);
-}
-
-
-void
-mp_mask_u16(const MPNumber *s1, MPNumber *t1)
-{
-    char text[MAX_DIGITS];
-    size_t len, offset;
-    
-    /* Convert to a hexadecimal string and use last 4 characters */
-    mp_cast_to_string(text, MAX_DIGITS, s1, 16, 0);
-    len = strlen(text);
-    offset = len > 4 ? len - 4: 0;
+    offset = current_wordlen / 4;
+    offset = len > offset ? len - offset: 0;
     mp_set_from_string(text + offset, 16, t1);
 }
 
@@ -140,3 +148,20 @@ mp_shift(MPNumber *s, MPNumber *t, int times)
         mpcmim(&temp, t);
     }
 }
+
+
+void
+mp_1s_complement(const MPNumber *s, MPNumber *t)
+{
+    MPNumber temp;
+    mp_set_from_integer(0, &temp);
+    mp_bitwise(s, &temp, mp_bitwise_xnor, t, current_wordlen);
+}
+
+
+void
+mp_2s_complement(const MPNumber *s, MPNumber *t)
+{
+    mp_1s_complement (s, t);
+    mp_add_integer (t, 1, t);
+}
diff --git a/gcalctool/mp.h b/gcalctool/mp.h
index 7690b6b..e127ec5 100644
--- a/gcalctool/mp.h
+++ b/gcalctool/mp.h
@@ -135,13 +135,16 @@ void mp_tan(const MPNumber *x, MPNumber *z);
 void mp_tanh(const MPNumber *x, MPNumber *z);
 
 /* mp-binary.c */
+void mp_set_wordlen(int);
+int  mp_is_overflow(const MPNumber *s1);
 void mp_and(const MPNumber *s1, const MPNumber *s2, MPNumber *t);
 void mp_or(const MPNumber *s1, const MPNumber *s2, MPNumber *t);
 void mp_xor(const MPNumber *s1, const MPNumber *s2, MPNumber *t);
 void mp_xnor(const MPNumber *s1, const MPNumber *s2, MPNumber *t);
 void mp_not(const MPNumber *s1, MPNumber *t);
-void mp_mask_u32(const MPNumber *s1, MPNumber *t1);
-void mp_mask_u16(const MPNumber *s1, MPNumber *t1);
+void mp_mask(const MPNumber *s1, MPNumber *t1);
 void mp_shift(MPNumber *s, MPNumber *t, int times);
+void mp_1s_complement(const MPNumber *s, MPNumber *res);
+void mp_2s_complement(const MPNumber *s, MPNumber *res);
 
 #endif /* MP_H */
diff --git a/gcalctool/parser.h b/gcalctool/parser.h
index 0a30ada..019e0e7 100644
--- a/gcalctool/parser.h
+++ b/gcalctool/parser.h
@@ -30,6 +30,7 @@
 #define PARSER_ERR_TOO_LONG_NUMBER 		10001
 #define PARSER_ERR_BITWISEOP		    	10002
 #define PARSER_ERR_MODULUSOP		    	10003
+#define PARSER_ERR_OVERFLOW			10004
 
 struct parser_state {
     int flags;
diff --git a/gcalctool/ui.h b/gcalctool/ui.h
index 0f08f8e..f008231 100644
--- a/gcalctool/ui.h
+++ b/gcalctool/ui.h
@@ -53,6 +53,7 @@ void ui_set_trigonometric_mode(TrigType);
 void ui_set_numeric_mode(BaseType);
 void ui_set_show_thousands_separator(gboolean);
 void ui_set_show_trailing_zeroes(gboolean);
+void ui_set_wordlen(int);
 
 void ui_set_error_state(gboolean);
 void ui_set_statusbar(const gchar *, const gchar *);
diff --git a/help/C/figures/gcalctool_programming_window.png b/help/C/figures/gcalctool_programming_window.png
index 5121d3d..7bcb6a6 100644
Binary files a/help/C/figures/gcalctool_programming_window.png and b/help/C/figures/gcalctool_programming_window.png differ
diff --git a/help/C/gcalctool.xml b/help/C/gcalctool.xml
index ce11fa0..63b14c5 100644
--- a/help/C/gcalctool.xml
+++ b/help/C/gcalctool.xml
@@ -1860,6 +1860,45 @@ after entering the exponent.</para>
 		  </tgroup>
 		</table>
     </sect3>
+    <sect3 id="gcalctool-word-length">
+      <title>To Set the Word Length</title>
+      <para>The word length can be altered, to make the bitwise functions behave differently. To set the word length, select one of the buttons described in <xref linkend="gcalctool-TBL-word-length"/>. </para>
+                <table id="gcalctool-TBL-word-length" frame="all">
+                  <title>Setting the Word Length</title>
+                  <tgroup cols="3" colsep="1" rowsep="1">
+                         <colspec colname="COLSPEC0" colwidth="50*"/>
+                         <colspec colname="COLSPEC1"/>
+                         <colspec colname="COLSPEC2" colwidth="50*"/>
+                         <thead>
+                                <row valign="top">
+                                  <entry colname="COLSPEC0">
+                                         <para>Function</para></entry>
+                                  <entry colname="COLSPEC1">
+                                         <para>Button</para></entry>
+                                  <entry colname="COLSPEC2">
+                                         <para>Description</para></entry>
+                                </row>
+                         </thead> 
+                         <tbody> 
+                           <row valign="top">
+                             <entry><para>64 bit word</para> </entry>
+                             <entry><para><guibutton>64 bit</guibutton></para></entry>
+                             <entry><para>Sets the word length to 64 bits. 64 bits is the default word length.</para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para>32 bit word</para> </entry>
+                             <entry><para><guibutton>32 bit</guibutton></para></entry>
+                             <entry><para>Sets the word length to 32 bits.</para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para>16 bit word</para> </entry>
+                             <entry><para><guibutton>16 bit</guibutton></para></entry>
+                             <entry><para>Sets the word length to 16 bits.</para></entry>
+                           </row>
+			 </tbody>
+		  </tgroup>
+		</table>
+    </sect3>
     <sect3 id="gcalctool-calc-bit-manipulation-ext">
       <title>To Perform Bit Manipulations on Integers</title>
       <para>If the calculator display shows an integer value, then each of the bits in that integer value is displayed as a collection of 0's and 1's in the Bit Editor. By clicking on any of these individual bits, their value can be toggled, causing the displayed integer value to be adjusted accordingly.</para>
@@ -1893,40 +1932,37 @@ after entering the exponent.</para>
                            <row valign="top">
                              <entry><para>Bitwise OR</para> </entry>
                              <entry><para><guibutton>OR</guibutton></para></entry>
-                             <entry><para>Performs a bitwise OR operation on the current value in the display area and the next number that you enter, treating both numbers as unsigned long integers.</para></entry>
+                             <entry><para>Performs a bitwise OR operation on the current value in the display area and the next number that you enter.</para></entry>
                              <entry><para>10001000 <guibutton>OR</guibutton> 00010001</para></entry>
                              <entry><para>10011001</para></entry>
                            </row>
                            <row valign="top">
                              <entry><para>Bitwise AND</para> </entry>
                              <entry><para><guibutton>AND</guibutton></para></entry>
-                             <entry><para>Performs a bitwise AND operation on the current value in the display area and the next number that you enter, treating both numbers as unsigned long integers.</para></entry>
+                             <entry><para>Performs a bitwise AND operation on the current value in the display area and the next number that you enter.</para></entry>
                              <entry><para>10101010 <guibutton>AND</guibutton> 00110011</para></entry>
                              <entry><para>100010</para></entry>
                            </row>
                            <row valign="top">
                              <entry><para>Bitwise NOT</para> </entry>
                              <entry><para><guibutton>NOT</guibutton></para></entry>
-                             <entry><para>Performs a bitwise NOT operation on the current value in the display area, treating the number as an unsigned long integer.</para></entry>
-                             <entry><para>For arithmetic precedence mode:</para>
-                             <para><guibutton>NOT</guibutton> 1357ACE</para>
-                             <para>For non-arithmetic precedence mode:</para>
-                             <para>1357ACE <guibutton>NOT</guibutton></para></entry>
+                             <entry><para>Performs a bitwise NOT operation on the current value in the display area, using the word size configured in <xref linkend="gcalctool-word-length"/>.</para></entry>
+                             <entry><para><guibutton>NOT</guibutton> 1357ACE</para></entry>
                              <entry><para>FECA8531</para></entry>
                            </row>
                            <row valign="top">
                              <entry><para>Bitwise XOR</para> </entry>
                              <entry><para><guibutton>XOR</guibutton></para></entry>
-                             <entry><para>Performs a bitwise XOR operation on the current value in the display area and the next number that you enter, treating both numbers as unsigned long integers.</para></entry>
+                             <entry><para>Performs a bitwise XOR operation on the current value in the display area and the next number that you enter.</para></entry>
                              <entry><para>1100 <guibutton>XOR</guibutton> 1010</para></entry>
                              <entry><para>110</para></entry>
                            </row>
                            <row valign="top">
                              <entry><para>Bitwise XNOR</para> </entry>
                              <entry><para><guibutton>XNOR</guibutton></para></entry>
-                             <entry><para>Performs a bitwise XNOR operation on the current value in the display area and the next number that you enter, treating both numbers as unsigned long integers.</para></entry>
+                             <entry><para>Performs a bitwise XNOR operation on the current value in the display area and the next number that you enter.</para></entry>
                              <entry><para>1100 <guibutton>XNOR</guibutton> 1010</para></entry>
-                             <entry><para>11111111111111111111111111111001</para></entry>
+                             <entry><para>1001</para></entry>
                            </row>
 			 </tbody>
 		  </tgroup>
@@ -1961,30 +1997,37 @@ after entering the exponent.</para>
                            <row valign="top">
                              <entry><para>Left Shift <replaceable>n</replaceable></para> </entry>
                              <entry><para><guibutton>&lt;</guibutton></para></entry>
-                             <entry><para>Shifts the current unsigned 32-bit binary value in the display area, the specified number of places to the left. Click <guibutton>&lt;</guibutton>, then select the number of shift places from the popup menu. The number can be shifted up to 15 places left. </para></entry>
+                             <entry><para>Shifts the current value in the display area, the specified number of places to the left. Click <guibutton>&lt;</guibutton>, then select the number of shift places from the popup menu. The number can be shifted up to 15 places left. </para></entry>
                              <entry><para>111 <guibutton>&lt;</guibutton> <guilabel>1 place</guilabel></para></entry>
                              <entry><para>1110</para></entry>
                            </row>
                            <row valign="top">
                              <entry><para>Right Shift <replaceable>n</replaceable></para> </entry>
                              <entry><para><guibutton>&gt;</guibutton></para></entry>
-                             <entry><para>Shifts the current unsigned 32-bit binary value in the display area, the specified number of places to the right. Click <guibutton>&gt;</guibutton>, then select the number of shift places from the popup menu. The number can be shifted up to 15 places right.</para></entry>
+                             <entry><para>Shifts the current value in the display area, the specified number of places to the right. Click <guibutton>&gt;</guibutton>, then select the number of shift places from the popup menu. The number can be shifted up to 15 places right.</para></entry>
                              <entry><para>1011 <guibutton>&gt;</guibutton> <guilabel>1 place</guilabel></para></entry>
                              <entry><para>101 </para></entry>
                            </row>
                            <row valign="top">
-                             <entry><para>Get a 16-Bit Unsigned Integer</para> </entry>
-                             <entry><para><guibutton>&amp;16</guibutton></para></entry>
-                             <entry><para>Truncates the current value in the display area and returns a 16-bit unsigned integer.</para></entry>
-                             <entry><para>FFFFF <guibutton>&amp;16</guibutton></para></entry>
-                             <entry><para>FFFF</para></entry>
+                             <entry><para>Truncating a number</para> </entry>
+                             <entry><para><guibutton>Trunc</guibutton></para></entry>
+                             <entry><para>Truncates the current value in the display area to the word size configured in <xref linkend="gcalctool-word-length"/>.</para></entry>
+                             <entry><para>FFFFFFFFFF <guibutton>Trunc</guibutton></para></entry>
+                             <entry><para>FFFFFFFF</para></entry>
                            </row>
                            <row valign="top">
-                             <entry><para>Get a 32-Bit Unsigned Integer</para> </entry>
-                             <entry><para><guibutton>&amp;32</guibutton></para></entry>
-                             <entry><para>Truncates the current value in the display area and returns a 32-bit unsigned integer.</para></entry>
-                             <entry><para>FFFFFFFFFF <guibutton>&amp;32</guibutton></para></entry>
-                             <entry><para>FFFFFFFF</para></entry>
+                             <entry><para>Get the 1's complement</para> </entry>
+                             <entry><para><guibutton>1's</guibutton></para></entry>
+                             <entry><para>Calculates the 1's complement for the current value in the display area, using the word size configured in <xref linkend="gcalctool-word-length"/>.</para></entry>
+                             <entry><para>D723 <guibutton>1's</guibutton></para></entry>
+                             <entry><para>FFFF28DC</para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para>Get the 2's complement</para> </entry>
+                             <entry><para><guibutton>2's</guibutton></para></entry>
+                             <entry><para>Calculates the 2's complement for the current value in the display area, using the word size configured in <xref linkend="gcalctool-word-length"/>.</para></entry>
+                             <entry><para>D723 <guibutton>2's</guibutton></para></entry>
+                             <entry><para>FFFF28DD</para></entry>
                            </row>
 			 </tbody>
 		  </tgroup>
@@ -2446,6 +2489,18 @@ the addition of:
                              <entry><para><xref linkend="gcalctool-TBL-financial-calc"/></para> </entry>
                            </row>
                            <row valign="top">
+                             <entry><para><keycap>Z</keycap></para></entry>
+                             <entry><para><guibutton>2's</guibutton></para></entry>
+                             <entry><para>2's complement</para></entry>
+                             <entry><para><xref linkend="gcalctool-TBL-num-manip"/></para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para><keycap>z</keycap></para></entry>
+                             <entry><para><guibutton>1's</guibutton></para></entry>
+                             <entry><para>1's complement</para></entry>
+                             <entry><para><xref linkend="gcalctool-TBL-num-manip"/></para></entry>
+                           </row>
+                           <row valign="top">
                              <entry><para><keycap>!</keycap></para></entry>
                              <entry><para><guibutton><replaceable>x</replaceable>!</guibutton></para></entry>
                              <entry><para><replaceable>x</replaceable> factorial</para> </entry>
@@ -2549,14 +2604,8 @@ the addition of:
                            </row>
                            <row valign="top">
                              <entry><para><keycap>[</keycap></para></entry>
-                             <entry><para><guibutton>&amp;32</guibutton></para></entry>
-                             <entry><para>Get a 32-bit unsigned integer</para> </entry>
-                             <entry><para><xref linkend="gcalctool-TBL-num-manip"/></para> </entry>
-                           </row>
-                           <row valign="top">
-                             <entry><para><keycap>]</keycap></para></entry>
-                             <entry><para><guibutton>&amp;16</guibutton></para></entry>
-                             <entry><para>Get a 16-bit unsigned integer</para> </entry>
+                             <entry><para><guibutton>Trunc</guibutton></para></entry>
+                             <entry><para>Truncates the number</para> </entry>
                              <entry><para><xref linkend="gcalctool-TBL-num-manip"/></para> </entry>
                            </row>
                            <row valign="top">
@@ -2614,6 +2663,24 @@ the addition of:
                          </thead> 
                          <tbody> 
                            <row valign="top">
+                             <entry><para><keycombo><keycap>Alt</keycap><keycap>1</keycap></keycombo></para></entry>
+                             <entry><para><guilabel>16 bit</guilabel></para></entry>
+                             <entry><para>Set the word size to 16 bits.</para></entry>
+                             <entry><para><xref linkend="gcalctool-TBL-word-length"/></para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para><keycombo><keycap>Alt</keycap><keycap>3</keycap></keycombo></para></entry>
+                             <entry><para><guilabel>32 bit</guilabel></para></entry>
+                             <entry><para>Set the word size to 32 bits.</para></entry>
+                             <entry><para><xref linkend="gcalctool-TBL-word-length"/></para></entry>
+                           </row>
+                           <row valign="top">
+                             <entry><para><keycombo><keycap>Alt</keycap><keycap>6</keycap></keycombo></para></entry>
+                             <entry><para><guilabel>64 bit</guilabel></para></entry>
+                             <entry><para>Set the word size to 64 bits.</para></entry>
+                             <entry><para><xref linkend="gcalctool-TBL-word-length"/></para></entry>
+                           </row>
+                           <row valign="top">
                              <entry><para><keycombo><keycap>Alt</keycap><keycap>a</keycap></keycombo></para></entry>
                              <entry><para><guilabel>Gradians</guilabel></para></entry>
                              <entry><para>Set the trigonometric type to gradians.</para></entry>
diff --git a/help/ChangeLog b/help/ChangeLog
index e8c353b..68effaa 100644
--- a/help/ChangeLog
+++ b/help/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-04 Robin Sonefors <ozamosi flukkost nu>
+
+	* C/gcalctool.xml: Added word size, 1's and 2's complement documentation, updated documentation for other bitwise functions (Bug #581253)
+	* C/figures/gcalctool_programming_window.png: Updated screenshot
+
 2009-04-08  Simos Xenitellis  <simos gnome org>
 
 	* el/el.po: Added Greek translation.



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