summaryrefslogtreecommitdiffhomepage
path: root/compat/round.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/round.hpp')
-rw-r--r--compat/round.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/compat/round.hpp b/compat/round.hpp
new file mode 100644
index 00000000..90a0ccb3
--- /dev/null
+++ b/compat/round.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <cmath>
+
+template<typename t>
+inline int iround(const t& val)
+{
+ return int(std::round(val));
+}
+
+template<typename t>
+inline unsigned uround(const t& val)
+{
+ return std::round(std::fmax(t(0), val));
+}