#40187 [NEW]: mt_rand(), rand()

2007-01-21 Thread callawey at gmail dot com
From: callawey at gmail dot com
Operating system: windows xp
PHP version:  5.2.0
PHP Bug Type: Math related
Bug description:  mt_rand(), rand()

Description:

rand and mt_rand generates random lenght integer between -99 and
+99. 

example mt_rand(1000, );
outputs: -564, -688852, 558988, -68889558

Reproduce code:
---
$str = mt_rand(1000, );

Expected result:

positive numbers between 1000 and 

Actual result:
--
-492911349,1162038978,-219333642

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


#40187 [Bgs]: mt_rand(), rand()

2007-01-21 Thread callawey at gmail dot com
 ID:   40187
 User updated by:  callawey at gmail dot com
 Reported By:  callawey at gmail dot com
 Status:   Bogus
 Bug Type: Math related
 Operating System: windows xp
 PHP Version:  5.2.0
 New Comment:

while($row = $DB-fetchArray($result))
{
for($i=0;$i=12;$i++)
{
$str .= rand(0,9);
}
//$str = mt_rand(1000, );  

$sqlc = sprintf(UPDATE %s SET user_id='%s' WHERE 
id='%s',
$DB-prefix(users), $str, $row[id]);
$DB-queryF($sqlc);
}



this code makes all colums -1


Previous Comments:


[2007-01-21 19:10:58] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Integer overflow on 32 bit systems is the cause.



[2007-01-21 19:06:47] callawey at gmail dot com

Description:

rand and mt_rand generates random lenght integer between -99
and +99. 

example mt_rand(1000, );
outputs: -564, -688852, 558988, -68889558

Reproduce code:
---
$str = mt_rand(1000, );

Expected result:

positive numbers between 1000 and 

Actual result:
--
-492911349,1162038978,-219333642





-- 
Edit this bug report at http://bugs.php.net/?id=40187edit=1


#40187 [Bgs]: mt_rand(), rand()

2007-01-21 Thread callawey at gmail dot com
 ID:   40187
 User updated by:  callawey at gmail dot com
 Reported By:  callawey at gmail dot com
 Status:   Bogus
 Bug Type: Math related
 Operating System: windows xp
 PHP Version:  5.2.0
 New Comment:

while($row = $DB-fetchArray($result))
{
$str = ;
for($i=0;$i=12;$i++)
{
$str .= rand(0,9);
}

$sqlc = sprintf(UPDATE %s SET user_id='%s' WHERE 
id='%s',
$DB-prefix(users), $str, $row[id]);
$DB-queryF($sqlc);
}

this returns same number everytime even i use $str = ; in every loop
Why ?


Previous Comments:


[2007-01-21 19:12:02] callawey at gmail dot com

while($row = $DB-fetchArray($result))
{
for($i=0;$i=12;$i++)
{
$str .= rand(0,9);
}
//$str = mt_rand(1000, );  

$sqlc = sprintf(UPDATE %s SET user_id='%s' WHERE 
id='%s',
$DB-prefix(users), $str, $row[id]);
$DB-queryF($sqlc);
}



this code makes all colums -1



[2007-01-21 19:10:58] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Integer overflow on 32 bit systems is the cause.



[2007-01-21 19:06:47] callawey at gmail dot com

Description:

rand and mt_rand generates random lenght integer between -99
and +99. 

example mt_rand(1000, );
outputs: -564, -688852, 558988, -68889558

Reproduce code:
---
$str = mt_rand(1000, );

Expected result:

positive numbers between 1000 and 

Actual result:
--
-492911349,1162038978,-219333642





-- 
Edit this bug report at http://bugs.php.net/?id=40187edit=1