Large Numbers

Thread Solved

Join Date: Jul 2007
Posts: 5
Reputation: edu2004eu is an unknown quantity at this point 
Solved Threads: 0
edu2004eu edu2004eu is offline Offline
Newbie Poster

Large Numbers

 
0
  #1
Aug 26th, 2007
Hello. I am currently having a problem with a script. I am using the rand() function to make big randomized numbers. The problem is that rand() only returns numbers lower than about 2 billion. I need more than that. Is there any function in PHP that gives you REALLY BIG randomized numbers? Or do you know a custom made script for this?

Thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: Large Numbers

 
0
  #2
Aug 26th, 2007
I don't know if it possible, because there are a limit in rand() and the processor, but if you really want only large numbers you could concatenate them with dots and min and max parameters, like:

  1. $big_num = rand(32765, 32768). rand(32763, 32765). rand(10000, 32768). rand(32763, 32767). rand(15000, 32768). rand(18000, 32768);
  2.  
  3. echo $big_num;
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 189
Reputation: martin5211 is an unknown quantity at this point 
Solved Threads: 14
martin5211 martin5211 is offline Offline
Junior Poster

Re: Large Numbers

 
0
  #3
Aug 26th, 2007
And another method, I've created a mini function:

  1. function big_num() {
  2.  
  3. for ($i = 1; $i <= rand(60,80); $i++) {
  4. $a .= rand(1, 32768);
  5. }
  6.  
  7. return $a;
  8. }
  9.  
  10. echo big_num();
Last edited by martin5211; Aug 26th, 2007 at 3:11 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 5
Reputation: edu2004eu is an unknown quantity at this point 
Solved Threads: 0
edu2004eu edu2004eu is offline Offline
Newbie Poster

Re: Large Numbers

 
0
  #4
Aug 26th, 2007
It worked. Thank you a million times!!! You don't know how gratefull I am to you...

Originally Posted by martin5211 View Post
And another method, I've created a mini function:

  1. function big_num() {
  2.  
  3. for ($i = 1; $i <= rand(60,80); $i++) {
  4. $a .= rand(1, 32768);
  5. }
  6.  
  7. return $a;
  8. }
  9.  
  10. echo big_num();
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC