How to make random numbers?

Got a problem you cannot solve? Try here.
Post Reply
Mark Fulford
Posts: 25
Joined: Tue May 23, 2006 2:22 pm

How to make random numbers?

Post by Mark Fulford »

I want three random numbers from my script in the range 0 to 50000 that are different each time the script is run on the same PC.

I am generating the number as follows:
RANDOM1 = Generate Random Number (max value 50000)
RANDOM2 = Generate Random Number (max value 50000)
RANDOM3 = Generate Random Number (max value 50000)

These are sample results:
RANDOM1 = 2400
RANDOM2 = 700
RANDOM3 = 1300

RANDOM1 = 4300
RANDOM2 = 2700
RANDOM3 = 4700

RANDOM1 = 1400
RANDOM2 = 2900
RANDOM3 = 3500

Clearly I've got something wrong, but what?
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Post by Gizm0 »

And what is the actual result?
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

I believe the max of this function is 32767, in case that is what's bothering you with the results.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Post by Gizm0 »

Yes, the MAX_INT value on Windows is 32767..If you want more, you have to multiply it, or create a custom dll and get the result from there!
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
Install[b]Aware[/b] Software Corporation
Mark Fulford
Posts: 25
Joined: Tue May 23, 2006 2:22 pm

Post by Mark Fulford »

The help file does not give sufficient detail of functions such as this. For example, what are the purposes of the two seed parameters?
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

They seed the random number generator with the specified number. Each seed must be unique for the random number generation to be truly pseudo-random. Please see the Serial Validation example project for detailed real-world usage of these functions.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Mark Fulford
Posts: 25
Joined: Tue May 23, 2006 2:22 pm

Post by Mark Fulford »

What I'm getting at is that the Help file is a bit light. For each function it should include information about parameters and results, such as the limit to the size of a random number and the range for seeds. A worked example within the Help file would also be quite normal.
Post Reply