note 10445 deleted from language.operators by sniper

From: Date: Mon, 13 Oct 2003 00:02:48 +0000
Subject: note 10445 deleted from language.operators by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58351@lists.php.net to get a copy of this message
Note Submitter: kees@tweakers.net ---- Normally, a negative value modulo a positive number generates a negaive number, if you don't want that (for example, the number has to be between 0 and 9 and not negative) then you can use a function like this: function mod($a,$b) { if ($a <= 0) return (int) mod($b-abs($a), $b); else return (int) $a % $b; } for example: -2 % 10 = -2 but mod(-2, 10) will return 8.

« previous php.notes (#58351) next »