summaryrefslogtreecommitdiff
path: root/mod.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'mod.hpp')
-rw-r--r--mod.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/mod.hpp b/mod.hpp
new file mode 100644
index 0000000..f0da7c4
--- /dev/null
+++ b/mod.hpp
@@ -0,0 +1,10 @@
+#pragma once
+#include <cmath>
+
+double mod(double a, double b) {
+ if (a >= 0) {
+ return fmod(a, b);
+ } else {
+ return fmod(a + b * ceil(-a / b), b);
+ }
+}