]> git.localhorst.tv Git - l2e.git/blobdiff - src/math/utility.h
added fixed point number type
[l2e.git] / src / math / utility.h
diff --git a/src/math/utility.h b/src/math/utility.h
new file mode 100644 (file)
index 0000000..2111df0
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef MATH_UTILITY_H_
+#define MATH_UTILITY_H_
+
+
+namespace math {
+
+template<class Int>
+Int DistanceShift(Int what, int lhs, int rhs) {
+       if (lhs < rhs) {
+               return what >> (rhs - lhs);
+       } else {
+               return what << (lhs - rhs);
+       }
+}
+
+}
+
+#endif