Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Big ints and random ints

by Masem (Monsignor)
on Jan 31, 2002 at 14:54 UTC ( #142423=note: print w/replies, xml ) Need Help??


in reply to Big ints and random ints

Generate the random number by sticking together N random digits to get. For example, if you want a random number between 1e30 and 9.99e39:
my $num = join '', map { int rand 10 } (0..(30 + int rand 10) );
Update actually, you don't even need the rand at the end; to go from 0 to 9.99e39:
my $num = join '', map { int rand 10 } (0..39);
as numbers of 38 digits or less will have zeroes prepended to them.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://142423]
help
Chatterbox?
[ambrus]: Corion: re stops the timer, sure, but stopping won't erase events already queued, right?
[ambrus]: really I don't know how it works

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2016-12-09 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.