aboutsummaryrefslogtreecommitdiff
path: root/src/base/math/round.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/math/round.c')
-rw-r--r--src/base/math/round.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/base/math/round.c b/src/base/math/round.c
new file mode 100644
index 0000000..a815152
--- /dev/null
+++ b/src/base/math/round.c
@@ -0,0 +1,13 @@
+#include <u.h>
+#include <base.h>
+
+double
+math·round(double x)
+{
+ double f;
+
+ f = math·floor(x);
+ if((x-f) > 0.5)
+ return f+1;
+ return f;
+}