Search results for 'count'. 1 post(s) found.
- 2007/08/26 A Function Returns Large Random Numbers
This basically Randomly pick a number between the min and max values. This is made because the rand() and mt_rand() function can not accept numbers larger than 2^31 or 2^63,depend on your processor and complier.
<?php
function bcrand($min,$max){
bcscale(0);
if(bccomp($max,$min)!=1){
return 0;
}
$top = bcsub($max,$min);
$rand = bcadd($top,1);
$length = strlen($top);
$n = 0;
while(9*$n <= $length){
if($length - 9*$n >= 9){
$rand_part[] = rand(0,999999999);
}else{
$j = 0; $foo = '';
while($j < $length-9*$n){
$foo .= '9';
$j;
}
$foo = 0;
$rand_part[] = rand(0,$foo);
}
$n;
}
$i = 0;
$rand ='';
$count = count($rand_part);
while($i < $count){
$rand .= $rand_part[$i];
$i;
}
while(bccomp($rand,$top)==1){
$rand = substr($rand,1,strlen($rand)).rand(0,9);
}
return bcadd($rand,$min);
}
?>
function bcrand($min,$max){
bcscale(0);
if(bccomp($max,$min)!=1){
return 0;
}
$top = bcsub($max,$min);
$rand = bcadd($top,1);
$length = strlen($top);
$n = 0;
while(9*$n <= $length){
if($length - 9*$n >= 9){
$rand_part[] = rand(0,999999999);
}else{
$j = 0; $foo = '';
while($j < $length-9*$n){
$foo .= '9';
$j;
}
$foo = 0;
$rand_part[] = rand(0,$foo);
}
$n;
}
$i = 0;
$rand ='';
$count = count($rand_part);
while($i < $count){
$rand .= $rand_part[$i];
$i;
}
while(bccomp($rand,$top)==1){
$rand = substr($rand,1,strlen($rand)).rand(0,9);
}
return bcadd($rand,$min);
}
?>
Another posts included in "PHP"
| Number Format (0) | 2007/08/26 |
| Calculator with basic four functions (0) | 2007/08/26 |
| Array_count_values (0) | 2007/08/26 |
| Function AccountCryptPassword($password,$salt) (0) | 2007/08/26 |
| Cardinal Endings (0) | 2007/08/25 |
| URL Rewriter PHP (0) | 2007/08/25 |
Trackback : Cannot send a trackbact to this post.
-
Subject Xanax valium.
2008/12/14 18:13
Interresults valium. Valium liquid form. Valium.
-
Subject Ultram tramadol.
2008/12/29 03:37
Ultram. Ultram wont make you fail a drug test. Hyperlink korea bulletin board on get ultram. Ultram ortho mcneil. Ultram side effects.
-
Subject Buy tramadol.
2009/03/04 12:18
Buy tramadol online cod. Buy cheap tramadol mg tablets only in us online.
-
Subject different money making ideas
2010/01/29 02:22
moneyideas
-
Subject different money making ideas
2010/01/29 10:36
moneyideas
-
Subject different money making ideas
2010/01/31 16:43
moneyideas

Prev

Rss Feed