From e6f5f9e03f673db796f1babb308609ca2576db2f Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 6 Aug 2023 01:54:27 +0200 Subject: Improve MC::Position and remove some redundant code --- src/Math/Mod.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Math/Mod.hpp (limited to 'src/Math') 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 +auto mod(A a, B b) -> decltype(a % b) { + return (a % b + b) % b; +} + +} \ No newline at end of file -- cgit 1.4.1