Generate a random numer

@param integer $max
@param integer $max 2,796,203 largest possible max
176743
public function generate($min = 0, $max = null)
    {  
        if($max === null) {
            $max = 2796203;
        }
        
        if($max > 2796203) {
            throw new ReverseRegexException('Max param has exceeded the maxium 2796203');
        }
        
        if ($this->seed == 0) {
            $this->seed(mt_rand());
        }
        
        $this->seed = ($this->seed * 125) % 2796203;  
        
        
        return $this->seed % ($max - $min + 1) + $min;  
    }
739938
private static function randFloat($min, $max, $decimals = 0.01)
    {
        $decimals = 1 / $decimals;

        return mt_rand($min * $decimals, $max * $decimals) / $decimals;
    }
1297389
public static function randNum($min = null, $max = null)
    {
        mt_srand((double) microtime() * 1000000);
        if ($min === null || $max === null) {
            return mt_rand();
        } else {
            return mt_rand($min, $max);
        }
    }
164132
public function setMaxOccurances($num)
    {
        if(is_integer($num) === false){
            throw new GeneratorException('Number must be an integer');
        }
        
        $this[self::REPEAT_MAX_INDEX] = $num;
        
    }
256268
public function setMax($max)
    {
        if (!is_int($max)) {
            throw new \InvalidArgumentException('The attribute max on the class Attribute has to be integer (' . gettype($max) . ('object' === gettype($max) ? ' ' . get_class($max) : '') . ' given).');
        }

        $this->max = $max;

        return $this;
    }
1066318
public function getInteger($min, $max)
    {
        $min = (int) $min;
        $max = (int) $max;

        if ($this->isOutOfBounds($min, 0, $max)) {
            throw new \InvalidArgumentException('Invalid minimum or maximum value');
        }

        return $this->generator->getNumber($min, $max);
    }
959237
public static int random(final int min, final int max) {
        return min + new java.security.SecureRandom().nextInt(max - min + 1);
    }
363183
public function getRandomNumber($min = -1, $max = -1) {
		if ($this->nextRandomNumber >= 0 && $this->nextRandomNumber >= ($min == -1 ? 0 : $min) && $this->nextRandomNumber <= ($max == -1 ? $this->getMaxRandomNumber() : $max)) {
			$rand = $this->nextRandomNumber;
			$this->nextRandomNumber = -1;

			return $rand;
		}

		return $this->realRandom->getRandomNumber($min, $max);
	}
322373
private function setMaxSteps($max)
    {
        $this->max = max(0, (int) $max);
        $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
    }
1173727
public static function generateRandomInt($min, $max)
    {
        $range = $max - $min;
        $bits = $bytes = $mask = $val = 0;
        while ($range > 0) {
            if ($bits % 8 === 0) {
               ++$bytes;
            }
            ++$bits;
            $range >>= 1;
            $mask = $mask << 1 | 1;
        }
        $valueShift = $min;

        do {
            if ($attempts > 128) {
                throw new \Exception('Could not generate valid random integer');
            }
            $randomByteString = self::generateCryptoKey($bytes);

            $val = 0;
            for ($i = 0; $i < $bytes; ++$i) {
                $val |= ord($randomByteString[$i]) << ($i * 8);
            }

            $val &= $mask;
            $val += $valueShift;

            ++$attempts;

        } while (!is_int($val) || $val > $max || $val < $min);

        return (int) $val;
    }
317644
public function generateInt($min = 0, $max = PHP_INT_MAX)
    {
        $tmp   = (int) max($max, $min);
        $min   = (int) min($max, $min);
        $max   = $tmp;
        $range = $max - $min;
        if ($range == 0) {
            return $max;
        } elseif ($range > PHP_INT_MAX || is_float($range) || $range < 0) {
            /**
             * This works, because PHP will auto-convert it to a float at this point,
             * But on 64 bit systems, the float won't have enough precision to
             * actually store the difference, so we need to check if it's a float
             * and hence auto-converted...
             */
            throw new \RangeException(
                'The supplied range is too great to generate'
            );
        }

        $bits  = $this->countBits($range) + 1;
        $bytes = (int) max(ceil($bits / 8), 1);
        if ($bits == 63) {
            /**
             * Fixes issue #22
             *
             * @see https://github.com/ircmaxell/RandomLib/issues/22
             */
            $mask = 0x7fffffffffffffff;
        } else {
            $mask = (int) (pow(2, $bits) - 1);
        }

        /**
         * The mask is a better way of dropping unused bits.  Basically what it does
         * is to set all the bits in the mask to 1 that we may need.  Since the max
         * range is PHP_INT_MAX, we will never need negative numbers (which would
         * have the MSB set on the max int possible to generate).  Therefore we
         * can just mask that away.  Since pow returns a float, we need to cast
         * it back to an int so the mask will work.
         *
         * On a 64 bit platform, that means that PHP_INT_MAX is 2^63 - 1.  Which
         * is also the mask if 63 bits are needed (by the log(range, 2) call).
         * So if the computed result is negative (meaning the 64th bit is set), the
         * mask will correct that.
         *
         * This turns out to be slightly better than the shift as we don't need to
         * worry about "fixing" negative values.
         */
        do {
            $test   = $this->generate($bytes);
            $result = hexdec(bin2hex($test)) & $mask;
        } while ($result > $range);

        return $result + $min;
    }
263406
public function setMax($max)
    {
        
    	// Support .x notation.
    	if (!empty($max)){
        	$this->max = preg_replace('/x/u', '99999', $max);
    	}
    	else{
    		$this->max = null;
    	}
        
    }
1356664
public function setMinMax($min,$max=null)
    {
       $this->min = $min; 
       $this->max = $max; 
    }
393815
public function length($min, $max = PHP_INT_MAX)
    {
        return $this->markErrorIf(strlen($this->value) < $min || strlen($this->value) > $max);
    }
263058
public function setMax(float $max) : self
    {
        $this->getField()->addAttribute('max', (string) $max);

        return $this;
    }
334164
public function setMax($max)
    {
        if (is_array($max) and isset($max['max'])) {
            $max = $max['max'];
        }

        if (!is_string($max) and !is_numeric($max)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception ('Invalid options to validator provided');
        }

        $max = (integer) $max;
        if (($this->_min !== null) && ($max < $this->_min)) {
            // require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but "
                                            . "$max < {$this->_min}");
        }

        $this->_max = $max;
        return $this;
    }
345844
public static final double random(double max) {
        last = (last * IA + IC) % IM;
        return max * last / IM;
    }