From add33a2a7f689611d2b76029a0d5597281f684bc Mon Sep 17 00:00:00 2001 From: reinelt Date: Tue, 5 Apr 2005 04:46:06 +0000 Subject: [lcd4linux @ 2005-04-05 04:46:06 by reinelt] ceil/floor patch from Maxime git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@526 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- plugin_math.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/plugin_math.c b/plugin_math.c index d1216a9..e5a3cc0 100644 --- a/plugin_math.c +++ b/plugin_math.c @@ -1,4 +1,4 @@ -/* $Id: plugin_math.c,v 1.7 2005/01/18 06:30:23 reinelt Exp $ +/* $Id: plugin_math.c,v 1.8 2005/04/05 04:46:06 reinelt Exp $ * * math plugin * @@ -23,6 +23,9 @@ * * * $Log: plugin_math.c,v $ + * Revision 1.8 2005/04/05 04:46:06 reinelt + * ceil/floor patch from Maxime + * * Revision 1.7 2005/01/18 06:30:23 reinelt * added (C) to all copyright statements * @@ -135,6 +138,18 @@ static void my_max (RESULT *result, RESULT *arg1, RESULT *arg2) SetResult(&result, R_NUMBER, &value); } +static void my_floor (RESULT *result, RESULT *arg) +{ + double value = floor(R2N(arg)); + SetResult(&result, R_NUMBER, &value); +} + +static void my_ceil (RESULT *result, RESULT *arg) +{ + double value = ceil(R2N(arg)); + SetResult(&result, R_NUMBER, &value); +} + int plugin_init_math (void) { @@ -155,6 +170,10 @@ int plugin_init_math (void) AddFunction ("min", 2, my_min); AddFunction ("max", 2, my_max); + /* floor, ceil */ + AddFunction ("floor", 1, my_floor); + AddFunction ("ceil", 1, my_ceil); + return 0; } -- cgit v1.2.3