summary refs log tree commit diff
path: root/src/Math/Mod.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-08-06 01:54:27 +0200
committerMel <einebeere@gmail.com>2023-08-06 01:54:27 +0200
commite6f5f9e03f673db796f1babb308609ca2576db2f (patch)
treefbc7d9451ec943a107f0ab54b3de7a7bd25e656d /src/Math/Mod.hpp
parenta627fb7038c94de9be9709ea88dcd1dddc95c5a3 (diff)
downloadmeowcraft-e6f5f9e03f673db796f1babb308609ca2576db2f.tar.zst
meowcraft-e6f5f9e03f673db796f1babb308609ca2576db2f.zip
Improve MC::Position and remove some redundant code
Diffstat (limited to 'src/Math/Mod.hpp')
-rw-r--r--src/Math/Mod.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Math/Mod.hpp b/src/Math/Mod.hpp
new file mode 100644
index 0000000..d686ad9
--- /dev/null
+++ b/src/Math/Mod.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+namespace Math {
+
+// Returns the least nonnegative remainder of a % b.
+// Euclidian definition of modulo.
+template <typename A, typename B>
+auto mod(A a, B b) -> decltype(a % b) {
+    return (a % b + b) % b;
+}
+
+}
\ No newline at end of file