954,202 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Large Numbers

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!

edu2004eu
Newbie Poster
5 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

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:

$big_num = rand(32765, 32768). rand(32763, 32765). rand(10000, 32768). rand(32763, 32767). rand(15000, 32768). rand(18000, 32768);

echo $big_num;
martin5211
Posting Whiz in Training
271 posts since Aug 2007
Reputation Points: 52
Solved Threads: 23
 

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

function big_num() {
	
	for ($i = 1; $i <= rand(60,80); $i++) {
		$a .= rand(1, 32768);
	}
	
	return $a;
}

echo big_num();
martin5211
Posting Whiz in Training
271 posts since Aug 2007
Reputation Points: 52
Solved Threads: 23
 

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

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

function big_num() {
	
	for ($i = 1; $i <= rand(60,80); $i++) {
		$a .= rand(1, 32768);
	}
	
	return $a;
}

echo big_num();
edu2004eu
Newbie Poster
5 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You