Edit report at https://bugs.php.net/bug.php?id=64450&edit=1
ID: 64450 Patch added by: a...@php.net Reported by: stefano dot baccianella at gmail dot com Summary: mt_rand causes overflow within certain max value Status: Open Type: Bug Package: *General Issues Operating System: Windows 7 64bit PHP Version: 5.4.13 Block user comment: N Private report: N New Comment: The following patch has been added/updated: Patch Name: bug64450.patch Revision: 1363874609 URL: https://bugs.php.net/patch-display.php?bug=64450&patch=bug64450.patch&revision=1363874609 Previous Comments: ------------------------------------------------------------------------ [2013-03-19 01:02:13] stefano dot baccianella at gmail dot com Description: ------------ When using mt_rand function using pow(10,12) as MAX parameter the function seems to get an overflow giving the warning: PHP Warning: mt_rand(): max(-727379968) is smaller than min(0) But the function works perfectly when using greater MAX value like pow(10,13) Below the diff of my php.ini and the php.ini-development provided by default: short_open_tag = On error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE include_path = ".;C:\Program Files (x86)\PHP\pear" extension=php_bz2.dll extension=php_curl.dll extension=php_gd2.dll extension=php_gettext.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_openssl.dll extension=php_pdo_pgsql.dll extension=php_pgsql.dll extension=php_apc.dll extension=php_sockets.dll ;extension=php_sqlite.dll extension=php_sqlite3.dll date.timezone = Europe/Rome [apc] [APC] apc.enabled = 1 apc.shm_segments = 1 apc.shm_size = 512M apc.num_files_hint = 1000 apc.user_entries_hint = 4096 apc.ttl = 0 apc.user_ttl = 0 apc.gc_ttl = 3600 apc.cache_by_default = 1 apc.filters = "apc\.php$" apc.mmap_file_mask = "/tmp/apc.XXXXXX" apc.slam_defense = 0 apc.file_update_protection = 2 apc.enable_cli = 0 apc.max_file_size = 10M apc.use_request_time = 1 apc.stat = 1 apc.write_lock = 1 apc.report_autofilter = 0 apc.include_once_override = 0 apc.localcache = 0 apc.localcache.size = 256M apc.coredump_unmap = 0 apc.stat_ctime = 0 apc.canonicalize = 1 Test script: --------------- <? echo mt_rand(0,pow(10,12)); echo mt_rand(0,pow(10,13)); ?> Expected result: ---------------- (a random number)(a random number) Actual result: -------------- PHP Warning: mt_rand(): max(-727379968) is smaller than min(0) (a random number) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64450&edit=1