944,173 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 903
  • PHP RSS
Aug 26th, 2007
0

Large Numbers

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
edu2004eu is offline Offline
5 posts
since Jul 2007
Aug 26th, 2007
0

Re: Large Numbers

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:

php Syntax (Toggle Plain Text)
  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;
Reputation Points: 52
Solved Threads: 23
Posting Whiz in Training
martin5211 is offline Offline
271 posts
since Aug 2007
Aug 26th, 2007
0

Re: Large Numbers

And another method, I've created a mini function:

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 52
Solved Threads: 23
Posting Whiz in Training
martin5211 is offline Offline
271 posts
since Aug 2007
Aug 26th, 2007
0

Re: Large Numbers

It worked. Thank you a million times!!! You don't know how gratefull I am to you...

Click to Expand / Collapse  Quote originally posted by martin5211 ...
And another method, I've created a mini function:

php Syntax (Toggle Plain Text)
  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();
Reputation Points: 10
Solved Threads: 0
Newbie Poster
edu2004eu is offline Offline
5 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to insert image in MySQL.......
Next Thread in PHP Forum Timeline: receiving an XML Post - how to ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC