How to make random numbers?

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

How to make random numbers?

Postby Mark Fulford » Fri Jun 23, 2006 8:49 am

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

Postby Gizm0 » Fri Jun 23, 2006 1:23 pm

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\"
InstallAware Software Corporation

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Fri Jun 23, 2006 3:04 pm

I believe the max of this function is 32767, in case that is what's bothering you with the results.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Postby Gizm0 » Fri Jun 23, 2006 3:43 pm

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\"

InstallAware Software Corporation

Mark Fulford
Posts: 25
Joined: Tue May 23, 2006 2:22 pm

Postby Mark Fulford » Mon Jun 26, 2006 3:14 am

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:

Postby MichaelNesmith » Mon Jun 26, 2006 5:26 pm

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

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/

Mark Fulford
Posts: 25
Joined: Tue May 23, 2006 2:22 pm

Postby Mark Fulford » Tue Jun 27, 2006 3:14 am

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.


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 148 guests