From:             burg1 at gmx dot net
Operating system: 
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  rand: include a notice that "max" parameter must not exceed 
getrandmax()

Description:
------------
I'm suggestion to revise this sentence in the docs:
"If you require a range larger than 32768, specifying min and max will
allow you to create a range larger than RAND_MAX, or consider using
mt_rand() instead."

1) As far as I can see, the max parameter cannot be larger than
getrandmax(), otherwise rand() always returns 0. Please mention this
limit! (I'm not sure if this behavior is platform-depended or due to
PHP-internal integer handling, so I cannot suggest a reformulation.)

2) As far as I can see, this limit also applies to mt_rand(), so the last
subsentence "or consider using mt_rand() instead" doesn't make sense to
me.

3) Since mt_rand generates a "better random value", please include an
explicit Note about this fact.


-- 
Edit bug report at http://bugs.php.net/?id=40408&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40408&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40408&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40408&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40408&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40408&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40408&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40408&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40408&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40408&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40408&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40408&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40408&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40408&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40408&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40408&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40408&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40408&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40408&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40408&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40408&r=mysqlcfg

Reply via email to