aboutsummaryrefslogtreecommitdiff
path: root/src/base/math
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-12-10 09:16:08 -0800
committerNicholas Noll <nbnoll@eml.cc>2021-12-10 09:16:08 -0800
commit25537c3d3b9b68af91573dec39d1f46c3d97f735 (patch)
tree3f2ea6207a28fe9610d767dd78fb24d17f858ce0 /src/base/math
parentf4aef385bdd41b02ef58b5366fa9318ecdc6e37e (diff)
Checkin: small sprawling updates
Small touches to multiple locations in base. Nothing major
Diffstat (limited to 'src/base/math')
-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;
+}