aboutsummaryrefslogtreecommitdiffstats
path: root/expression.c
diff options
context:
space:
mode:
authorreinelt <>2003-10-06 05:51:15 +0000
committerreinelt <>2003-10-06 05:51:15 +0000
commit6c589b92922f00b5eb91f36fdfa23a19a670999e (patch)
tree060ee6f17c464a8cc28f2fd05d37d4b99e1eece6 /expression.c
parent1a1db25a3f98aeae655641eaeb533d5a8916c07e (diff)
downloadlcd4linux-6c589b92922f00b5eb91f36fdfa23a19a670999e.tar.gz
[lcd4linux @ 2003-10-06 05:51:15 by reinelt]
functions: min(), max()
Diffstat (limited to '')
-rw-r--r--expression.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/expression.c b/expression.c
index f051170..7fc15fd 100644
--- a/expression.c
+++ b/expression.c
@@ -1,4 +1,4 @@
-/* $Id: expression.c,v 1.2 2003/10/06 05:47:27 reinelt Exp $
+/* $Id: expression.c,v 1.3 2003/10/06 05:51:15 reinelt Exp $
*
* expression handling
*
@@ -22,6 +22,9 @@
*
*
* $Log: expression.c,v $
+ * Revision 1.3 2003/10/06 05:51:15 reinelt
+ * functions: min(), max()
+ *
* Revision 1.2 2003/10/06 05:47:27 reinelt
* operators: ==, \!=, <=, >=
*
@@ -95,6 +98,23 @@ static void my_tan (RESULT *result, RESULT *arg1)
}
+static void my_min (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+ double a1=R2N(arg1);
+ double a2=R2N(arg2);
+ double value=a1<a2?a1:a2;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+static void my_max (RESULT *result, RESULT *arg1, RESULT *arg2)
+{
+ double a1=R2N(arg1);
+ double a2=R2N(arg2);
+ double value=a1>a2?a1:a2;
+ SetResult(&result, R_NUMBER, &value);
+}
+
+
static void my_strlen (RESULT *result, RESULT *arg1)
{
double value=strlen(R2S(arg1));
@@ -124,6 +144,10 @@ int EX_init (void)
AddFunction ("cos", 1, my_cos);
AddFunction ("tan", 1, my_tan);
+ // min, max
+ AddFunction ("min", 2, my_min);
+ AddFunction ("max", 2, my_max);
+
// register some basic string functions
AddFunction ("strlen", 1, my_strlen);