note 20741 deleted from language.operators by sniper

From: Date: Mon, 13 Oct 2003 00:03:24 +0000
Subject: note 20741 deleted from language.operators by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58356@lists.php.net to get a copy of this message
Note Submitter: ronm1958@adelphia.net ---- The PHP modulus function will (interestingly) not return the decimal portion of the result. I wrote a little function that will do so, and mimics the results obtained by using the Windows calculator mod function: function modphp($x, $y, $z) { for ($y = 0; $y <= abs($z); $y++) { $w = abs($z) - (abs($x) * $y); if ($w < abs($x)) { break; } } if ($z < 0) { return(-$w); } else { return($w); } } Here's how to pull the answer out of the mod function above: $answer = modphp($var_x, $var_y, $var_z);

« previous php.notes (#58356) next »