From 64f760c1483ad1b34c79557faa5fc27c2d86103d Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Mon, 23 May 2016 17:27:25 +0200 Subject: add it::mod which returns modulo as a positive number --- it.class | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'it.class') 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; +} + } -- cgit v1.2.3