Changeset 21685 for trunk/wp-includes/pluggable.php
- Timestamp:
- 08/31/2012 09:45:50 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pluggable.php
r21664 r21685 1497 1497 1498 1498 if ( !function_exists('wp_rand') ) : 1499 1499 /** 1500 1500 * Generates a random number 1501 1501 * 1502 1502 * @since 2.6.2 1503 1503 * 1504 * @param int $min Lower limit for the generated number (optional, default is 0)1505 * @param int $max Upper limit for the generated number (optional, default is 4294967295)1504 * @param int $min Lower limit for the generated number 1505 * @param int $max Upper limit for the generated number 1506 1506 * @return int A random number between min and max 1507 1507 */ … … 1532 1532 $value = abs(hexdec($value)); 1533 1533 1534 // Some misconfigured 32bit environments (Entropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. 1535 $max_random_number = 3000000000 === 2147483647 ? (float) "4294967295" : 4294967295; // 4294967295 = 0xffffffff 1536 1534 1537 // Reduce the value to be within the min - max range 1535 // 4294967295 = 0xffffffff = max random number1536 1538 if ( $max != 0 ) 1537 $value = $min + ( ($max - $min + 1) * ($value / (4294967295 + 1)));1539 $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); 1538 1540 1539 1541 return abs(intval($value));
Note: See TracChangeset
for help on using the changeset viewer.