To get a number that is actually in the full range of an INT, you need to make two separate calls, and add them together. Then convert that unsigned INT value into a signed INT value.
PHP Code:
<?PHP
// Returns negative numbers as if (-2147483647,0)
$z = mt_rand(0,2147483648);
// Returns mostly 1 or negative numbers
$z = mt_rand(-2147483647,2147483647);
// Returns negative numbers, but within range set???
// So much for returning only values from 0 to Max
$z = mt_rand(-2147483647,0);
// Attempt to stay within the range/spread of mt_getrandmax()
// Results are odd, like 180 to 2147478000
$z = mt_rand(2147483647,4294967294);
// Works, but it should not, as the value is not an INT
// Values are converted to floor(x), so range is (0,0)
$z = mt_rand(0.000001,0.9999999);
?>
Bookmarks