rand function with range always returns low value of range
| Bug #24909 | rand function with range always returns low value of range | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2003-08-01 14:37 UTC | Modified: | 2003-08-08 08:36 UTC |
|
||||||||||
| From: | a0 at hush dot com | Assigned: | ||||||||||||
| Status: | Closed | Package: | Math related | |||||||||||
| PHP Version: | 4.3.3RC3-dev | OS: | solaris 8 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2003-08-01 14:37 UTC] a0 at hush dot com
Description: ------------ when using the rand function with php 4.3.2 on solaris 8, it will return a random value as expected if no range is specified. if a range is specified it will always return the low value of the range. i'm building the module with -DZTS, and it is being loaded into IWS4.1. i've modified the code so it works by changing line 36 of php_rand.h from #if HAVE_LRAND48 to #if (HAVE_LRAND48 && !sun) so PHP_RAND_MAX will get a value of RAND_MAX. Reproduce code: --------------- <? $r = rand(); echo "$r\n"; $r = rand(0, 100); echo "$r\n"; ?> Expected result: ---------------- 24384 0 (it will always return 0)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-08-02 12:46 UTC] iliaa@php.net
[2003-08-02 13:55 UTC] a0 at hush dot com
[2003-08-02 15:00 UTC] iliaa@php.net
[2003-08-02 15:17 UTC] a0 at hush dot com
[2003-08-04 08:39 UTC] sniper@php.net
[2003-08-04 12:18 UTC] a0 at hush dot com
[2003-08-07 15:48 UTC] thetaphi@php.net
[2003-08-08 08:36 UTC] iliaa@php.net