#24909 [Opn->Fbk]: rand function with range always returns low value of range

From: Date: Sat, 02 Aug 2003 17:47:00 +0000
Subject: #24909 [Opn->Fbk]: rand function with range always returns low value of range
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-45235@lists.php.net to get a copy of this message
ID: 24909 Updated by: iliaa@php.net Reported By: a0 at hush dot com -Status: Open +Status: Feedback Bug Type: Math related Operating System: solaris 8 PHP Version: 4.3.2 New Comment: I've asked a number of people to replicate the problem, however they were unable to do so using latest PHP and Solaris 8 & 9. Please try the latest snapshot of 4.3.3 and see if the problem persists. Previous Comments: ------------------------------------------------------------------------ [2003-08-01 14:37:22] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24909&edit=1

« previous php.bugs (#45235) next »