mirror of
https://github.com/php/php-src.git
synced 2026-03-24 16:22:37 +01:00
* random: Remove `php_rand()` This effectively is just a slim wrapper around `(zend_long)php_mt_rand()`. It is not compatible between 32-bit and 64-bit builds of PHP, due to the use of `zend_long`, which may result in negative integersbeing returned on 32-bit platforms, whereas 64-bit platforms will be compatible with `php_mt_rand()`. An example would be the `0` seed, which emits 2357136044 on 64-bit platforms and -1937831252 on 32-bit platforms. Users of `php_rand()` should ideally migrate to one of the more modern engines, with extension-specific state. If drop-in compatibility is desired, they can just cast the result of `php_mt_rand()`. But providing it out of the box does not provide a value-add and is potentially dangerous. * random: Remove `php_srand()` With `php_rand()` gone, preserving its companion `php_srand()` is just confusing. The same recommendations apply: Migrate to a modern engine if possible and just call `php_mt_srand()` with an appropriately casted input. * random: Remove `PHP_RAND_MAX` and `RAND_MAX` These are the companions to `php_rand()`, which was removed in a previous commit. Generally speaking the maximum returnable value is not particularly useful anyways. Attempting it to create a random float by dividing the returned integer by the maximum value would result in a bias if the maximum value would be larger than 2**53 and even for that case, the various `range()` helpers allow to easily retrieve a uniformly distributed integer from a suitable range. * UPGRADING.INTERNALS