Matt Fowles <[EMAIL PROTECTED]> writes:
> All~
>
> We could try to keep the opcode count down by simply having a seed
> opcode and an opcode to produce n random bytes... Anyone who wants
> more specific ranges could do the modulus and addition themselves.
The modulus/addition trick is very common but actually a bad idea. See
Press et al., Numerical Recipies in C, 2nd ed. or Linux rand(3):
"If you want to generate a random integer between 1
and 10, you should always do it by using high-order
bits, as in
j=1+(int) (10.0*rand()/(RAND_MAX+1.0));
and never by anything resembling
j=1+(rand() % 10);
(which uses lower-order bits)."
The best way to avoid this add/mod trick is to provide a convenient
way to get random numbers in ranges.
I like the basic idea of having different random number
generators. But having only the integer valued level seems a little
bit problematic to me. Its not easy extendable if you have some
special needs on the random number generator.
So I propose something completely new:
Use a PMC.
You don't need any special ops, only a special PMC.
creating a random number generator.
new P0, .RandomNumberGenerator
getting a integervalued random number
set I0, P0
getting a floatvalued random number
set N0, P0
Special versions of the random number generator like other ranges can
be created by initialisation arguments.
Thoughs
boe
--
Juergen Boemmels [EMAIL PROTECTED]
Fachbereich Physik Tel: ++49-(0)631-205-2817
Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906
PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47