From 22d6040dca2f9edf264c0b0438fce6975bbbfb7d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Oct 2016 21:00:52 +0200 Subject: [PATCH] Implementing more usefull functions --- Math/Functions/Functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index c68dc3883..8c435b3d6 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -205,4 +205,28 @@ class Functions return $t; } + + public static function mod($a, $b) { + if($a < 0) { + return ($a + $b) % $b; + } + + return $a % $b; + } + + public static function isOdd($a) : int { + if ($a & 1) { + return true; + } + + return false; + } + + public static function isEven($a) : int { + if ($a & 1) { + return false; + } + + return true; + } }