diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2003-10-06 05:51:15 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2003-10-06 05:51:15 +0000 |
commit | 80daed22ba0e5232d18dec3b8608edfa0f784987 (patch) | |
tree | 060ee6f17c464a8cc28f2fd05d37d4b99e1eece6 | |
parent | f6b9e43347e8a0dbbc6016ff3584dc56058135c8 (diff) | |
download | lcd4linux-80daed22ba0e5232d18dec3b8608edfa0f784987.tar.gz |
[lcd4linux @ 2003-10-06 05:51:15 by reinelt]
functions: min(), max()
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@258 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to '')
-rw-r--r-- | expression.c | 26 |
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); |