- abs: documentation ( source)
- rand: documentation ( source)
- getrandmax: documentation ( source)
<?php
$rand_min = -getrandmax ();
$rand_max = getrandmax ();
$c = 1000;
for ( $min = $rand_min; $min < 0; $min+=10000000 ) {
$diff = $rand_max - abs ( $min ) + 1;
$cnt = 0;
for ( $i = 0; $i < $c; $i++ ) {
$super_random_value = rand ( $min, $rand_max );
if ( $super_random_value == $diff )
$cnt++;
}
$per = $cnt * 100 / $c;
echo "Number '${diff}' was generated ${cnt} times, " . $per . "%, minimum = ${min}\n";
}