[gcalctool] Support implicit multiply before functions, e.g. "6 log 3" (Robert Ancell, Bug #586812)



commit 042b43a1e3f2bd2f04e5f403ff96eab1d8e7112a
Author: Robert Ancell <robert ancell gmail com>
Date:   Wed Jun 24 13:43:04 2009 +1000

    Support implicit multiply before functions, e.g. "6 log 3" (Robert Ancell, Bug #586812)
    Use inverse notation for trigonometric functions, i.e. "asin" -> "sin�¹"
    Use lowercase notation for trigonometric and logarithm functions to look
    Put spacing around functions, i.e. "sin" -> " sin "
    Use subscript for logarithm base two, i.e. "log2" -> "logâ??"

 ChangeLog                |   12 +++-
 data/gcalctool.ui        |   20 +++---
 src/functions.c          |   34 +++++-----
 src/gtk.c                |   36 +++++-----
 src/mp-equation-lexer.l  |   36 +++++------
 src/mp-equation-parser.y |    4 +-
 src/unittest.c           |  157 +++++++++++++++++++++++++---------------------
 7 files changed, 161 insertions(+), 138 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3ee4284..13dcca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,16 @@
 gcalctool change history.
 =========================
 
+2009-06-24 Robert Ancell <robert ancell gmail com>
+
+    * Support implicit multiply before functions, e.g. "6 log 3"
+      (Robert Ancell, Bug #586812)
+    * Use inverse notation for trigonometric functions, i.e. "asin" -> "sin�¹"
+    * Use lowercase notation for trigonometric and logarithm functions to look
+      more like standard mathematical notation
+    * Put spacing around functions, i.e. "sin" -> " sin "
+    * Use subscript for logarithm base two, i.e. "log2" -> "logâ??"
+
 2009-06-16 Robert Ancell <robert ancell gmail com>
 
     * README:
@@ -55,7 +65,7 @@ gcalctool change history.
 
 2009-05-07 Robert Ancell <robert ancell gmail com>
 
-    * Add a --solve command-line argument (Robert Ancell)
+    * Add a --solve command-line argument (Robert Ancell, Bug #361758)
 
 2009-05-04 Robert Ancell <robert ancell gmail com>
 
diff --git a/data/gcalctool.ui b/data/gcalctool.ui
index b4ef03b..190da9a 100644
--- a/data/gcalctool.ui
+++ b/data/gcalctool.ui
@@ -2838,13 +2838,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">(Log)</property>
+                <property name="tooltip_text" translatable="yes">(log)</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
                 <child>
                   <object class="GtkLabel" id="logarithm_label">
                     <property name="visible">True</property>
-                    <property name="label" comments="Varable label button - text set inside gtk.c">(Log)</property>
+                    <property name="label" comments="Varable label button - text set inside gtk.c">(log)</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
@@ -2861,13 +2861,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">(Log2)</property>
+                <property name="tooltip_text" translatable="yes">(log2)</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
                 <child>
                   <object class="GtkLabel" id="logarithm2_label">
                     <property name="visible">True</property>
-                    <property name="label" comments="Variable function button - text set inside gtk.c">(Log2)</property>
+                    <property name="label" comments="Variable function button - text set inside gtk.c">(log2)</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
@@ -3011,13 +3011,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">(Tan)</property>
+                <property name="tooltip_text" translatable="yes">(tan)</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
                 <child>
                   <object class="GtkLabel" id="tangent_label">
                     <property name="visible">True</property>
-                    <property name="label" comments="Variable function button - text set inside gtk.c">(Tan)</property>
+                    <property name="label" comments="Variable function button - text set inside gtk.c">(tan)</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
@@ -3036,13 +3036,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">(Sin)</property>
+                <property name="tooltip_text" translatable="yes">(sin)</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
                 <child>
                   <object class="GtkLabel" id="sine_label">
                     <property name="visible">True</property>
-                    <property name="label" comments="Variable function button - text set inside gtk.c">(Sin)</property>
+                    <property name="label" comments="Variable function button - text set inside gtk.c">(sin)</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
@@ -3061,13 +3061,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">(Cos)</property>
+                <property name="tooltip_text" translatable="yes">(cos)</property>
                 <property name="focus_on_click">False</property>
                 <signal name="clicked" handler="button_cb"/>
                 <child>
                   <object class="GtkLabel" id="cosine_label">
                     <property name="visible">True</property>
-                    <property name="label" comments="Variable function button - text set inside gtk.c">(Cos)</property>
+                    <property name="label" comments="Variable function button - text set inside gtk.c">(cos)</property>
                     <property name="use_markup">True</property>
                   </object>
                 </child>
diff --git a/src/functions.c b/src/functions.c
index f98cf40..bc3bd67 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -94,26 +94,26 @@ static Function functions[NFUNCTIONS] = {
 { FN_X_POW_Y_INV,       "^(1/(", 0 },
 { FN_FACTORIAL,         "!", 0 },
 { FN_RANDOM,            "Rand", 0 },
-{ FN_SIN,               "Sin", FUNC },
-{ FN_SINH,              "Sinh", FUNC },
-{ FN_ASIN,              "Asin", FUNC },
-{ FN_ASINH,             "Asinh", FUNC },
-{ FN_COS,               "Cos", FUNC },
-{ FN_COSH,              "Cosh", FUNC },
-{ FN_ACOS,              "Acos", FUNC },
-{ FN_ACOSH,             "Acosh", FUNC },
-{ FN_TAN,               "Tan", FUNC },
-{ FN_TANH,              "Tanh", FUNC },
-{ FN_ATAN,              "Atan", FUNC },
-{ FN_TAN,               "Atanh", FUNC },
-{ FN_NATURAL_LOGARITHM, "Ln", FUNC },
-{ FN_LOGARITHM,         "Log", FUNC },
-{ FN_LOGARITHM2,        "Log2", FUNC },
+{ FN_SIN,               " sin ", 0 },
+{ FN_SINH,              " sinh ", 0 },
+{ FN_ASIN,              " sin�¹ ", 0 },
+{ FN_ASINH,             " asinh ", 0 },
+{ FN_COS,               " cos ", 0 },
+{ FN_COSH,              " cosh ", 0 },
+{ FN_ACOS,              " cos�¹ ", 0 },
+{ FN_ACOSH,             " acosh ", 0 },
+{ FN_TAN,               " tan ", 0 },
+{ FN_TANH,              " tanh ", 0 },
+{ FN_ATAN,              " tan�¹ ", 0 },
+{ FN_TAN,               " atanh ", 0 },
+{ FN_NATURAL_LOGARITHM, " ln ", 0 },
+{ FN_LOGARITHM,         " log ", 0 },
+{ FN_LOGARITHM2,        " logâ?? ", 0 },
 { FN_ABSOLUTE_VALUE,    "Abs", FUNC },
 { FN_TRUNC,             "Trunc", FUNC },
 { FN_MODULUS_DIVIDE,    " mod ", 0 },
-{ FN_1S_COMPLEMENT,     "1s", FUNC },
-{ FN_2S_COMPLEMENT,     "2s", FUNC },
+{ FN_1S_COMPLEMENT,     "ones", FUNC },
+{ FN_2S_COMPLEMENT,     "twos", FUNC },
 { FN_EXPONENTIAL,       "e", 0 },
 { FN_NOT,               "~", 0 },
 { FN_OR,                " OR ", 0 },
diff --git a/src/gtk.c b/src/gtk.c
index 5adc4cb..9101176 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -673,13 +673,13 @@ ui_update_modifier_mode()
 {
     static char *sine_labels[]      = {
         /* Translators: The sine button */
-        N_("Sin"),
+        N_("sin"),
         /* Translators: The inverse sine button */        
-        N_("Sin<sup>-1</sup>"),
+        N_("sin<sup>â??1</sup>"),
         /* Translators: The hyperbolic sine button */
-        N_("Sinh"),
+        N_("sinh"),
         /* Translators: The inverse hyperbolic sine button */
-        N_("Sinh<sup>-1</sup>")};
+        N_("sinh<sup>â??1</sup>")};
     static char *sine_tooltips[]    = {
         /* Translators: The sine tooltip */
         N_("Sine [k]"),
@@ -692,13 +692,13 @@ ui_update_modifier_mode()
     static int  sine_functions[]    = {FN_SIN, FN_ASIN, FN_SINH, FN_ASINH};
     static char *cosine_labels[]    = {
         /* Translators: The cosine button */
-        N_("Cos"),
+        N_("cos"),
         /* Translators: The inverse cosine button */        
-        N_("Cos<sup>-1</sup>"),
+        N_("cos<sup>â??1</sup>"),
         /* Translators: The hyperbolic cosine button */
-        N_("Cosh"),
+        N_("cosh"),
         /* Translators: The inverse hyperbolic cosine button */
-        N_("Cosh<sup>-1</sup>")};
+        N_("cosh<sup>â??1</sup>")};
     static char *cosine_tooltips[]  = {
         /* Translators: The cosine tooltip */
         N_("Cosine [j]"),
@@ -711,13 +711,13 @@ ui_update_modifier_mode()
     static int  cosine_functions[]  = {FN_COS, FN_ACOS, FN_COSH, FN_ACOSH};
     static char *tangent_labels[]   = {
         /* Translators: The tangent button */
-        N_("Tan"),
+        N_("tan"),
         /* Translators: The inverse tangent button */        
-        N_("Tan<sup>-1</sup>"),
+        N_("tan<sup>â??1</sup>"),
         /* Translators: The hyperbolic tangent button */
-        N_("Tanh"),
+        N_("tanh"),
         /* Translators: The inverse hyperbolic tangent button */
-        N_("Tanh<sup>-1</sup>")};
+        N_("tanh<sup>â??1</sup>")};
     static char *tangent_tooltips[] = {
         /* Translators: The tangent tooltip */
         N_("Tangent [w]"),
@@ -731,36 +731,36 @@ ui_update_modifier_mode()
     
     static char *ln_labels[]        = {
         /* Translators: The natural logaritm button */
-        N_("Ln"),
+        N_("ln"),
         /* Translators: The e to the power of x button */
         N_("e<sup><i>x</i></sup>")};
     static char *ln_tooltips[]      = {
         /* Translators: Tooltip for the natural log button */
-        N_("Natural log [n]"),
+        N_("Natural logarithm [n]"),
         /* Translators: Tooltip for the e to the power of x button */
         N_("e to the power of the displayed value [N]")};
     static int ln_functions[]       = {FN_NATURAL_LOGARITHM, FN_E_POW_X};
     
     static char *log_labels[]       = {
         /* Translators: The 10-based logaritm button */
-        N_("Log"),
+        N_("log"),
         /* Translators: The 10 to the power of x button */
         N_("10<sup><i>x</i></sup>")};
     static char *log_tooltips[]     = {
         /* Translators: Tooltip for the log base 10 button */
-        N_("Base 10 log [g]"),
+        N_("Base 10 logarithm [g]"),
         /* Translators: Tooltip for the 10 to the power of x button */
         N_("10 to the power of displayed value [G]")};
     static int log_functions[]      = {FN_LOGARITHM, FN_10_POW_X};
     
     static char *log2_labels[]      = {
         /* Translators: The 2-based logaritm button */
-        N_("Log<sub>2</sub>"),
+        N_("log<sub>2</sub>"),
         /* Translators: The 2 to the power of x button */
         N_("2<sup><i>x</i></sup>")};
     static char *log2_tooltips[]    = {
         /* Translators: Tooltip for the log base 2 button */
-        N_("Base 2 log [h]"),
+        N_("Base 2 logarithm [h]"),
         /* Translators: Tooltip for the 2 to the power of x button */
         N_("2 to the power of the displayed value [H]")};
     static int log2_functions[]     = {FN_LOGARITHM2, FN_2_POW_X};
diff --git a/src/mp-equation-lexer.l b/src/mp-equation-lexer.l
index 5394b38..3c1a971 100644
--- a/src/mp-equation-lexer.l
+++ b/src/mp-equation-lexer.l
@@ -57,45 +57,43 @@ BIN_NUM{BIN}+|{BIN}*{DECIMAL}{BIN}*
 "/"|"÷" {return tDIVIDE;}
 "abs"|"Abs"|"ABS" {return tABS_FUNC;}
 "|" {return tABS;}
-"acosh"|"Acosh"|"ACOSH" {return tACOSH;}
-"acos"|"Acos"|"ACOS" {return tACOS;}
+"sin"|"Sin"|"SIN" {return tSIN;}
+"cos"|"Cos"|"COS" {return tCOS;}
+"tan"|"Tan"|"TAN" {return tTAN;}
+"sin�¹"|"asin"|"Asin"|"ASIN" {return tASIN;}
+"cos�¹"|"acos"|"Acos"|"ACOS" {return tACOS;}
+"tan�¹"|"atan"|"Atan"|"ATAN" {return tATAN;}
+"sinh"|"Sinh"|"SINH" {return tSINH;}
+"cosh"|"Cosh"|"COSH" {return tCOSH;}
+"tanh"|"Tanh"|"TANH" {return tTANH;}
+"sinh�¹"|"asinh"|"Asinh"|"ASINH" {return tASINH;}
+"cosh�¹"|"acosh"|"Acosh"|"ACOSH" {return tACOSH;}
+"tanh�¹"|"atanh"|"Atanh"|"ATANH" {return tATANH;}
 "â?§"|"and"|"And"|"AND" {return tAND;}
 "ans"|"Ans"|"ANS" {return tANS;}
-"asinh"|"Asinh"|"ASINH" {return tASINH;}
-"asin"|"Asin"|"ASIN" {return tASIN;}
-"atanh"|"Atanh"|"ATANH" {return tATANH;}
-"atan"|"Atan"|"ATAN" {return tATAN;}
-"cbrt"|"Cbrt"|"CBRT" {return tCBRT;}
 "chs"|"Chs"|"CHS" {return tCHS;}
 "clr"|"Clr"|"CLR" {return tCLR;}
-"cosh"|"Cosh"|"COSH" {return tCOSH;}
-"cos"|"Cos"|"COS" {return tCOS;}
 "eng"|"Eng"|"ENG" {return tEXP;}
 "frac"|"Frac"|"FRAC" {return tFRAC;}
 "int"|"Int"|"INT" {return tINT;}
 "ln"|"Ln"|"LN" {return tLN;}
 "log"|"Log"|"LOG" {return tLOG10;}
-"log2"|"Log2"|"LOG2" {return tLOG2;}
+"logâ??"|"Logâ??"|"log_2"|"Log_2"|"LOG_2" {return tLOG2;}
 "mod"|"Mod"|"MOD" {return tMOD;}
 "¬"|"~" {return tNOT;}
 "â?¨"|"or"|"Or"|"OR" {return tOR;}
 "Ï?"|"pi"|"Pi"|"PI" {return tPI;}
 "rand"|"Rand"|"RAND" {return tRAND;}
 "rcl"|"Rcl"|"RCL" {return tRCL;}
-"sinh"|"Sinh"|"SINH" {return tSINH;}
-"sin"|"Sin"|"SIN" {return tSIN;}
-"sqrt"|"Sqrt"|"SQRT" {return tSQRT;}
-"â??" {return tROOT;}
-"â??" {return tROOT3;}
+"â??"|"sqrt"|"Sqrt"|"SQRT" {return tROOT;}
+"â??"|"cbrt"|"Cbrt"|"CBRT" {return tROOT3;}
 "â??" {return tROOT4;}
 "²" {return tSQUARED;}
 "³" {return tCUBED;}
 "sto"|"Sto"|"STO" {return tSTO;}
-"tanh"|"Tanh"|"TANH" {return tTANH;}
-"tan"|"Tan"|"TAN" {return tTAN;}
 "trunc"|"Trunc"|"TRUNC" {return tTRUNC;}
-"1s"|"1S" {return t1S;}
-"2s"|"2S" {return t2S;}
+"ones" {return t1S;}
+"twos" {return t2S;}
 "xnor"|"Xnor"|"XNOR" {return tXNOR;}
 "â??"|"xor"|"Xor"|"XOR" {return tXOR;}
 
diff --git a/src/mp-equation-parser.y b/src/mp-equation-parser.y
index 8d0108d..a8c6976 100644
--- a/src/mp-equation-parser.y
+++ b/src/mp-equation-parser.y
@@ -57,7 +57,6 @@
 %token tASINH
 %token tATAN
 %token tATANH
-%token tCBRT
 %token tCHS
 %token tCLR
 %token tCOS
@@ -145,7 +144,6 @@ udf:
 
 value: 
   exp {mp_set_from_mp(&$1, &$$);}
-| tPI %prec HIGH {mp_get_pi(&$$);} 
 ;
 
 exp: 
@@ -200,6 +198,7 @@ exp:
 
 term:
   number {mp_set_from_mp(&$1, &$$);}
+| tPI {mp_get_pi(&$$);}
 | rcl {mp_set_from_mp(&$1, &$$);}
 | tROOT term {mp_sqrt(&$2, &$$);}
 | tROOT3 term {mp_root(&$2, 3, &$$);}
@@ -224,6 +223,7 @@ term:
 | tADD term %prec POS {mp_set_from_mp(&$2, &$$);}
 | term '^' term {mp_xpowy(&$1, &$3, &$$);}
 
+| term func {mp_multiply(&$1, &$2, &$$);}
 | func {mp_set_from_mp(&$1, &$$);}
 | reg {mp_set_from_mp(&$1, &$$);}
 
diff --git a/src/unittest.c b/src/unittest.c
index 0645bd3..71a1d0b 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -102,12 +102,12 @@ test_parser()
     test("1", "1", 0);
     test("+1", "1", 0);
     test("++1", "1", 0);
-    test("--1", "1", 0);
+    test("â??â??1", "1", 0);
     test("255", "255", 0);
     test("256", "256", 0);
     test("1.00", "1", 0);
     test("1.01", "1.01", 0);
-    test("pi", "3.141592654", 0);
+    test("Ï?", "3.141592654", 0);
     test("1e3", "1000", 0);
     test("1e+3", "1000", 0);
     test("1e-3", "0.001", 0);
@@ -125,46 +125,49 @@ test_parser()
     test("40000â??0.001", "39999.999", 0);
     test("0.001â??40000", "â??39999.999", 0);
     test("40000000â??40000000", "0", 0);
-    test("2Ã?3", "6", 0);
     test("2*3", "6", 0);
-    test("â??2*3", "â??6", 0);
-    test("2*â??3", "â??6", 0);
-    test("â??2*â??3", "6", 0);
-    //FIXME: Need to update mperr() test("1/2", "0.5", 0);
-    //FIXME: Need to update mperr() test("1/0", "", 0);
-    //FIXME: Need to update mperr() test("0/0", "", 0);
-    test("6÷3", "2", 0);
+    test("2Ã?3", "6", 0);
+    test("â??2Ã?3", "â??6", 0);
+    test("2Ã?â??3", "â??6", 0);
+    test("â??2Ã?â??3", "6", 0);
+
     test("6/3", "2", 0);
-    test("â??6/3", "â??2", 0);
-    test("6/â??3", "â??2", 0);
-    test("â??6/â??3", "2", 0);
-    test("2/2", "1", 0);
-    test("1203/1", "1203", 0);
-    test("â??0/32352.689", "0", 0);
-    test("1/4", "0.25", 0);
-    test("(â??3)/(â??6)", "0.5", 0);
-    test("1/3", "0.333333333", 0);
-    test("2/3", "0.666666667", 0);    
-
-    test("1+2*3", "7", 0);
-    test("1+(2*3)", "7", 0);    
-    test("(1+2)*3", "9", 0);
+    test("6÷3", "2", 0);
+    test("1÷2", "0.5", 0);
+    test("â??6÷3", "â??2", 0);
+    test("6÷â??3", "â??2", 0);
+    test("â??6÷â??3", "2", 0);
+    test("2÷2", "1", 0);
+    test("1203÷1", "1203", 0);
+    test("â??0÷32352.689", "0", 0);
+    test("1÷4", "0.25", 0);
+    test("(â??3)÷(â??6)", "0.5", 0);
+    test("1÷3", "0.333333333", 0);
+    test("2÷3", "0.666666667", 0);
+    test("1÷0", "", -20001);
+    test("0÷0", "", -20001);
+
+    test("1+2Ã?3", "7", 0);
+    test("1+(2Ã?3)", "7", 0);    
+    test("(1+2)Ã?3", "9", 0);
     
     test("100%", "1", 0);
     test("1%", "0.01", 0);
     test("100+1%", "101", 0);
     test("100â??1%", "99", 0);
-    test("100*1%", "1", 0);
-    test("100/1%", "10000", 0);    
+    test("100Ã?1%", "1", 0);
+    test("100÷1%", "10000", 0);    
 
     test("0!", "1", 0);
     test("1!", "1", 0);
     test("5!", "120", 0);
     test("69!", "171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000", 0);
     test("0.1!", "", -20001);
-    test("â??1!", "â??1", 0);
-    test("(â??1)!", "", -20001);    
+    test("â??1!", "â??1", 0); // FIXME: Should be an error
+    test("(â??1)!", "", -20001);
 
+    test("2²", "4", 0);
+    test("2³", "8", 0);   
     test("2^0", "1", 0);
     test("2^1", "2", 0);
     test("2^2", "4", 0);
@@ -176,21 +179,19 @@ test_parser()
     test("4^3^2", "262144", 0);
     test("4^(3^2)", "262144", 0);    
     test("(4^3)^2", "4096", 0);
-    test("2²", "4", 0);
-    test("2³", "8", 0);
     test("â??4", "2", 0);
     test("â??4â??2", "0", 0);    
     test("â??8", "2", 0);
     test("â??16", "2", 0);
     test("â??(2+2)", "2", 0);
     test("2â??4", "4", 0);
-    test("2*â??4", "4", 0);
+    test("2Ã?â??4", "4", 0);
     test("Sqrt(4)", "2", 0);
     test("Sqrt(2)", "1.414213562", 0);
-    test("4^(1/2)", "2", 0);
-    test("2^(1/2)", "1.414213562", 0);
-    test("(â??4)^(1/2)", "", -20001);
-    test("(â??8)^(1/3)", "â??2", 0);
+    test("4^0.5", "2", 0);
+    test("2^0.5", "1.414213562", 0);
+    test("â??4^0.5", "", -20001);
+    test("â??8^(1÷3)", "â??2", 0);
     
     test("0 Mod 7", "0", 0);
     test("6 Mod 7", "6", 0);
@@ -208,58 +209,72 @@ test_parser()
     test("|3â??5|", "2", 0);    
     test("Abs(1)", "1", 0);
     test("Abs(â??1)", "1", 0);
-    
-    test("Ln(e^1)", "1", 0);
+
+    test("log â??1", "", -20001);
+    test("log 0", "", -20001);
+    test("log 1", "0", 0);
+    test("log 2", "0.301029996", 0);
+    test("log 10", "1", 0);
+    test("2 log 2", "0.602059991", 0);
+
+    test("ln â??1", "", -20001);
+    test("ln 0", "", -20001);    
+    test("ln 1", "0", 0);
+    test("ln 2", "0.693147181", 0);
+    test("ln e^1", "1", 0);
+    test("2 ln 2", "1.386294361", 0);
 
     v->ttype = MP_DEGREES;
-    test("Sin(0)", "0", 0);
-    test("Sin(45) â?? 1/Sqrt(2)", "0", 0);
-    test("Sin(20) + Sin(â??20)", "0", 0);
-    test("Sin(90)", "1", 0);
-    test("Sin(180)", "0", 0);
+    test("sin 0", "0", 0);
+    test("sin 45 â?? 1÷â??2", "0", 0);
+    test("sin 20 + sin(â??20)", "0", 0);
+    test("sin 90", "1", 0);
+    test("sin 180", "0", 0);
+    test("2 sin 90", "2", 0);
    
-    test("Cos(0)", "1", 0);
-    test("Cos(45) â?? 1/Sqrt(2)", "0", 0);
-    test("Cos(20) â?? Cos(â??20)", "0", 0);
-    test("Cos(90)", "0", 0);
-    test("Cos(180)", "â??1", 0);
+    test("cos 0", "1", 0);
+    test("cos 45 â?? 1÷â??2", "0", 0);
+    test("cos 20 â?? cos â??20", "0", 0);
+    test("cos 90", "0", 0);
+    test("cos 180", "â??1", 0);
+    test("2 cos 0", "2", 0);
 
-    test("Tan(0)", "0", 0);
-    test("Tan(10) â?? Sin(10)/Cos(10)", "0", 0);
-    test("Tan(90)", "", -20001);
+    test("tan 0", "0", 0);
+    test("tan 10 â?? sin 10÷cos 10", "0", 0);
+    test("tan 90", "", -20001);
 
-    test("Acos(0)", "90", 0);
-    test("Acos(1)", "0", 0);
-    test("Acos(â??1)", "180", 0);
-    test("Acos(1/Sqrt(2))", "45", 0);
+    test("cos�¹ 0", "90", 0);
+    test("cos�¹ 1", "0", 0);
+    test("cosâ?»Â¹ â??1", "180", 0);
+    test("cosâ?»Â¹ (1÷â??2)", "45", 0);
 
-    test("Asin(0)", "0", 0);
-    test("Asin(1)", "90", 0);
-    test("Asin(â??1)", "â??90", 0);
-    test("Asin(1/Sqrt(2))", "45", 0);
+    test("sin�¹ 0", "0", 0);
+    test("sin�¹ 1", "90", 0);
+    test("sinâ?»Â¹ â??1", "â??90", 0);
+    test("sinâ?»Â¹ (1÷â??2)", "45", 0);
 
-    test("Cosh(0)", "1", 0);
-    test("Cosh(10) â?? (e^(10)+e^(â??10))/2", "0", 0);
+    test("cosh 0", "1", 0);
+    test("cosh 10 â?? (e^(10)+e^(â??10))÷2", "0", 0);
 
-    test("Sinh(0)", "0", 0);
-    test("Sinh(10) â?? (e^(10)â??e^(â??10))/2", "0", 0);
-    test("Sinh(â??10) +Sinh(10)", "0", 0);
+    test("sinh 0", "0", 0);
+    test("sinh 10 â?? (e^(10)â??e^(â??10))÷2", "0", 0);
+    test("sinh â??10 + sinh 10", "0", 0);
 
-    test("Cosh(â??5)^2 â?? Sinh(â??5)^2", "1", 0);
-    test("Tanh(0)", "0", 0);
-    test("Tanh(10) â?? Sinh(10)/Cosh(10)", "0", 0);
+    test("(cosh â??5)² â?? (sinh â??5)²", "1", 0);
+    test("tanh 0", "0", 0);
+    test("tanh 10 â?? sinh(10)÷cosh(10)", "0", 0);
 
-    test("Atanh(0)", "0", 0);
-    test("Atanh(1/10) â?? 1/2*Ln(11/9)", "0", 0);
+    test("atanh 0", "0", 0);
+    test("atanh (1÷10) â?? 0.5 ln(11÷9)", "0", 0);
 
     v->ttype = MP_DEGREES;
-    test("Sin(90)", "1", 0);
+    test("sin 90", "1", 0);
     
     v->ttype = MP_RADIANS;
-    test("Sin(3.14159/2)", "1", 0);
+    test("sin (Ï?÷2)", "1", 0); // FIXME: Shouldn't need brackets
     
     v->ttype = MP_GRADIANS;
-    test("Sin(100)", "1", 0);
+    test("sin 100", "1", 0);
 
     v->base = HEX;
     test("3 And 5", "1", 0);



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