From 0d110e1506fe823401b6a325ce3da123762178ff Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Thu, 5 Aug 1999 21:23:48 +0200
Subject: [PATCH] Added the global function 'round' (and the alias 'rint')

Rev: src/modules/_math/math.c:1.18
---
 src/modules/_math/math.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/modules/_math/math.c b/src/modules/_math/math.c
index 2bb3972a55..1f44520fbf 100644
--- a/src/modules/_math/math.c
+++ b/src/modules/_math/math.c
@@ -24,7 +24,7 @@
 #include <floatingpoint.h>
 #endif
 
-RCSID("$Id: math.c,v 1.17 1999/03/31 13:12:37 mirar fake $");
+RCSID("$Id: math.c,v 1.18 1999/08/05 19:23:48 per Exp $");
 
 #ifndef M_PI
 #define M_PI 3.1415926535897932384626433832795080
@@ -198,6 +198,13 @@ void f_ceil(INT32 args)
   sp[-args].u.float_number=ceil(sp[-args].u.float_number);
 }
 
+void f_round(INT32 args)
+{
+  if(args<1) error("Too few arguments to round()\n");
+  if(sp[-args].type!=T_FLOAT) error("Bad argument 1 to round()\n");
+  sp[-args].u.float_number=rint(sp[-args].u.float_number);
+}
+
 void f_min(INT32 args)
 {
   INT32 i;
@@ -300,6 +307,12 @@ void pike_module_init(void)
 /* function(float:float) */
   ADD_EFUN("ceil",f_ceil,tFunc(tFlt,tFlt),0);
 
+/* function(float:float) */
+  ADD_EFUN("round",f_round,tFunc(tFlt,tFlt),0);
+
+/* function(float:float) */
+  ADD_EFUN("rint",f_round,tFunc(tFlt,tFlt),0);
+
 #define CMP_TYPE \
   "!function(!object...:mixed)&function(mixed...:mixed)|" \
   "function(int...:int)|" \
-- 
GitLab