aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math.js
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2022-07-05 23:34:03 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2022-07-05 23:34:03 +0200
commit2df937df1372359babd123d1361e702a1a4b8168 (patch)
treea44f4e3e51469c173127ce8660e39c20aa5309d7 /src/lib/math.js
parent3717f7fbf9ec110b51fe002cdced5d73ebd6136b (diff)
Create the sensor, move values to config
Diffstat (limited to 'src/lib/math.js')
-rw-r--r--src/lib/math.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/math.js b/src/lib/math.js
new file mode 100644
index 0000000..c745cdc
--- /dev/null
+++ b/src/lib/math.js
@@ -0,0 +1,8 @@
+/**
+ * Modulo that acts well with negative numbers.
+ * @param {number} dividend the number to divide
+ * @param {number} divisor the divisor to calculate the remainder
+ */
+export const modulo = function modulo (dividend, divisor) {
+ return ((dividend % divisor) + divisor) % divisor
+};