Search results for 'count'. 1 post(s) found.

  1. 2007/08/26 A Function Returns Large Random Numbers
2007/08/26 01:54

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);
}
?>

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 6 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Xanax valium.

    Tracked from Canada valium. 2008/12/14 18:13 delete

    Interresults valium. Valium liquid form. Valium.

  2. Subject Ultram tramadol.

    Tracked from Ultram. 2008/12/29 03:37 delete

    Ultram. Ultram wont make you fail a drug test. Hyperlink korea bulletin board on get ultram. Ultram ortho mcneil. Ultram side effects.

  3. Subject Buy tramadol.

    Tracked from Where buy tramadol click here. 2009/03/04 12:18 delete

    Buy tramadol online cod. Buy cheap tramadol mg tablets only in us online.

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 02:22 delete

    moneyideas

  5. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 10:36 delete

    moneyideas

  6. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:43 delete

    moneyideas