Rnd function improvements? 
Author Message
 Rnd function improvements?

Is there a way I can generate random numbers without using the rnd function?
I want whole numbers, not decimals.


Mon, 08 Mar 2004 05:22:33 GMT  
 Rnd function improvements?

Quote:

> Is there a way I can generate random numbers without using the rnd function?

Yes, you can implement your own pseudorandom algorithm, but it's not
easy to do a good job of it.

Quote:
> I want whole numbers, not decimals.

So why not just use Rnd?  If you want a number between 0 and 10
(including 0 but not including 10), just do

   myInt = Rnd*10

Won't this work for you?

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Mon, 08 Mar 2004 05:34:12 GMT  
 Rnd function improvements?

Quote:

> Is there a way I can generate random numbers without using the rnd function?
> I want whole numbers, not decimals

Multiply rnd by a scaling factor (to get yourself in the right range) and
assign to an integer (to get yourself a whole number). There's formulas to
help you on p. 147 of my book. m.

--

          *** REALbasic: The Definitive Guide! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt
             -- The Second Edition is coming! --



Mon, 08 Mar 2004 08:06:40 GMT  
 Rnd function improvements?

Quote:

> So why not just use Rnd?  If you want a number between 0 and 10
> (including 0 but not including 10), just do

>    myInt = Rnd*10

> Won't this work for you?

Joe, why has nobody added this to the online help for years?

Please add this example to the online help.

Thanks.

Mfg
Christian

--
Auf Windows 95 laufen so ziemlich alle Spiele.
Fuer ernsthaftes Arbeiten sollte man aber zusaetzlich ein
Betriebssystem installieren.
http://www.christians-software.de (Kostenlose Mac/Win Software)



Mon, 08 Mar 2004 10:25:07 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. RND Function Needed

2. RND Function Needed

3. RND FUNCTION NEEDED

4. HO ow to get RND function in F77

5. Rnd numbers

6. RND Help Please!

7. A RND command algorithm

8. Rnd from1 to 12

9. 2 VERY stupid questions: globals & rnd

10. A RND command algorithm

11. RND but between to values Question.

12. RND

 

 
Powered by phpBB® Forum Software