Thanks:  0
Likes:  0
Dislikes:  0

# Thread: Generating Random Integer

1. ## Generating Random Integer

Is there a better way to generate a random integer than SilkTest's RandInt() function? I need true random numbers that going through a loop will give a diffrent random number each time. How RandInt does it is you get the same number on a fast loop.

I did make a RandomInt() function (see below), which helps on general random numbers since it is using RandSeed(), but on a loop that just grabs some random numbers, I still get the same numbers.

Anyone have a better way?

------------------
David Genrich
Icarian
333 Moffett Park Drive
Sunnyvale, CA 94089
davidg@icarian.com

2. ## Re: Generating Random Integer

Here's an idea... Only an idea though

Try to have your function sleep a random time (1-3 seconds or so) and after the sleep call the RandInt () function.

You sort of call the RandInt twice one in each other. that doubles your Randomness chances.

Here's another idea:
------------------
AJ Alhait
BetaSoft Inc.

[This message has been edited by AJ (edited 11-01-1999).]

3. ## Re: Generating Random Integer

Or you could use the RndSeed function and set the seed value to the current time (converted to an integer).

4. ## Re: Generating Random Integer

Did use the random seed with the time - the numbers stay the same if you put it through a 11 count loop. Tried doing just the seconds. Still not enough. the code above I am taking the seconds multiplied by the seconds. That works for generall use if I am picking slowly. But if I want to run a loop that just grabs 50 numbers, they will all be the same.

The SilkTest Random algorthm is really bad. I understand that it isn't trully "random", it is a pseudo-random result set, but calling it several concutive time, using a random seed of seconds squared, one would think you could get somewhat diffrent numbers.

I am currently looking for a good mathmatical equation to create my own RandInt() funtion.

------------------
David Genrich
Icarian
333 Moffett Park Drive
Sunnyvale, CA 94089
davidg@icarian.com

5. ## Re: Generating Random Integer

OK, did some more testing on this and found I didn't really have a problem. In normal testing, I am using the RandomInt() function I posted above. This keeps the numbers from being the same each time I run the testcase. For running a loop that I was just many random integers, the default SilkTest RandInt() function with no RandSeed value applied will produce the desired randomness needed.

------------------
David Genrich
Icarian
333 Moffett Park Drive
Sunnyvale, CA 94089
davidg@icarian.com

6. ## Re: Generating Random Integer

Do you know that if you're just grabbing the second part, you are not doing a good job of randomizing.

Why don't you use the whole hours, minutes, and seconds? If you want to have more random, then you can modify the result number by itself, as you did in your original
code.

-Michael Hwee-

[This message has been edited by admin (edited 11-03-1999).]

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:13 PM.

Copyright BetaSoft Inc.