From: stefano dot baccianella at gmail dot com Operating system: Windows 7 64bit PHP version: 5.4.13 Package: *General Issues Bug Type: Bug Bug description:mt_rand causes overflow within certain max value
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 bug report at https://bugs.php.net/bug.php?id=64450&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64450&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64450&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64450&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64450&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64450&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64450&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64450&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64450&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64450&r=support Expected behavior: https://bugs.php.net/fix.php?id=64450&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64450&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64450&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64450&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64450&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64450&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64450&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64450&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64450&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64450&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64450&r=mysqlcfg