View Single Post
  #1 (permalink)  
Old Dec 24th, 2006, 00:03
Pheonix Pheonix is offline
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Problems with random numbers...

What should this code generate? My guess, 50 random numbers all between two fairly large numbers.
PHP: Select all

<ol><?php

for($x=0;$x<100;$x++)
{
echo 
'<li>'.mt_rand(48711122,2435556100).'</li>';
}
?></ol>
Actual Result? A little bit stranger...
HTML: Select all
<ol><li>-1399182791</li><li>-41036583</li><li>-1252920765</li><li>-526451647</li><li>-332961694</li><li>-1833380612</li><li>-1159768753</li><li>-1813882781</li><li>-1550466255</li><li>-68989001</li><li>-1659861049</li><li>-441480022</li><li>-183657088</li><li>-1277516243</li><li>-667125714</li>...
Okay... so... what now? I need a random generator to be able to handle numbers this large, I would simply times them all by -1, however some times it actually throws out a positive number, now I could come up with a way around that, but i'm sure there is a "proper" way to do this... right?
Reply With Quote