summaryrefslogtreecommitdiffhomepage
path: root/compat/round.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-18 12:28:25 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-18 12:34:58 +0100
commit364c1ecd8703dadaaa9c7479335e469b153a1be0 (patch)
treea2ba1f508c5007857d865cc06bb696de0e398038 /compat/round.hpp
parent11ef6b48676c52a42a81f1f5ee021cb37e728800 (diff)
compat: split/cleanup util.hpp
Some of the headers are clearly useless. Remove them. Move what's inside util.hpp into separate headers. Adjust usages. Will remove util.hpp.
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));
+}