summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorChristian Helbling2016-05-23 17:27:25 +0200
committerChristian Helbling2016-05-23 17:27:25 +0200
commit64f760c1483ad1b34c79557faa5fc27c2d86103d (patch)
tree1b4d1c5241f381a0982cdccea9966656f5362c3d /it.class
parent2bb032b36bd7314c7cf478805dec4f30e5624496 (diff)
downloaditools-64f760c1483ad1b34c79557faa5fc27c2d86103d.tar.gz
itools-64f760c1483ad1b34c79557faa5fc27c2d86103d.tar.bz2
itools-64f760c1483ad1b34c79557faa5fc27c2d86103d.zip
add it::mod which returns modulo as a positive number
Diffstat (limited to 'it.class')
-rw-r--r--it.class8
1 files changed, 8 insertions, 0 deletions
diff --git a/it.class b/it.class
index 9ade3a0..0ea9a2f 100644
--- a/it.class
+++ b/it.class
@@ -1061,4 +1061,12 @@ static function sort($array, $mode = "")
return $array;
}
+/**
+ * returns $a modulo $n as a positive number between 0 and $n - 1
+ */
+static function mod($a, $n)
+{
+ return (($a % $n) + $n) % $n;
+}
+
}