Ask a Question related to PHP Development, Design and Development.
-
a0 at hush dot com #1
#24909 [NEW]: rand function with range always returns low value of range
From: a0 at hush dot com
Operating system: solaris 8
PHP version: 4.3.2
PHP Bug Type: Math related
Bug description: rand function with range always returns low value of range
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)
--
Edit bug report at [url]http://bugs.php.net/?id=24909&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=24909&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=24909&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=24909&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=24909&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=24909&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=24909&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=24909&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=24909&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=24909&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=24909&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=24909&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=24909&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=24909&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=24909&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=24909&r=gnused[/url]
a0 at hush dot com Guest
-
#39464 [NEW]: Range function produces odd values in foreach loop
From: netnessie at gmail dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: *Programming Data Structures Bug... -
value out of range
Having a nightmare with this bit of code: member("3D World").shader("wallsz-clone1").textureTransform.scale = vector( 1.000, 2.000, 1.000 ) It... -
Date Range
I?ve got a routine that figure out 30 days from today?s date, but what I want to do is resolve a start date and an end date where the start date is... -
#24909 [Fbk->Opn]: rand function with range always returns low value of range
ID: 24909 User updated by: a0 at hush dot com Reported By: a0 at hush dot com -Status: Feedback +Status: ... -
#24909 [Opn->Fbk]: rand function with range always returns low value of range
ID: 24909 Updated by: iliaa@php.net Reported By: a0 at hush dot com -Status: Open +Status: Feedback...



Reply With Quote

