This code works by concatenating some random numbers, and then scaling the result to the appropriate size:
use strict; my $max = 3020300000; for ( 1 .. 10 ) { my $rnd = ""; my $div = "1"; for ( 0 .. length($max)/3 ) { $rnd .= sprintf( "%03d", int( rand( 1000 ) ) ); $div .= "000"; } my $return = int( $max * $rnd / $div ); print "$return\n"; } __END__ Output: 621716507 1535231762 2578709376 1912855527 1226418624 36225623 1231223131 1602498674 2831739360 1587564592
In reply to Re: What is the limit of random number that can be selected
by fglock
in thread What is the limit of random number that can be selected
by Sameet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |