note 38474 added to function.bcmod
| From: | lauris at night dot lt | Date: | Tue, 23 Dec 2003 13:04:35 +0000 |
| Subject: | note 38474 added to function.bcmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62373@lists.php.net to get a copy of this message | ||
/**
* my_bcmod - get modulus (substitute for bcmod)
* string my_bcmod ( string left_operand, int modulus )
* left_operand can be really big, but be carefull with modulus :(
* by Andrius Baranauskas and Laurynas Butkus :) Vilnius, Lithuania
**/
function my_bcmod( $x, $y )
{
// how many numbers to take at once? carefull not to exceed (int)
$take = 5;
$mod = '';
do
{
$a = (int)$mod.substr( $x, 0, $take );
$x = substr( $x, $take );
$mod = $a % $y;
}
while ( strlen($x) );
return (int)$mod;
}
// example
echo my_bcmod( "7044060001970316212900", 150 );
----
Manual Page -- http://www.php.net/manual/en/function.bcmod.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38474
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38474&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38474&report=yes
Search -- http://master.php.net/manage/user-notes.php