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

--

*** 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?

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

 Page 1 of 1 [ 4 post ]

Relevant Pages
 12. RND