News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Masmlib nrandom/nseed

Started by Jimg, November 27, 2007, 04:54:27 PM

Previous topic - Next topic

Jimg

I just found out by accident that zero is not a valid seed for nrandom.  It's obvious from examining how the code works, but I think that should be stated somewhere in the code of the routine and in Masmlib help.  Or better still perhaps, automatically modify a zero if it is found.

Larry Hammick

It won't be long before a hardware random number generator is standard equipment on PC's. A good system, already available for about US$1000, simply grabs photons from the environment and "measures" their spin: up or down. Each photon thus gives one random bit.
It'll be nice when our machines have a CPU register from which random data can be read at any time.

WillofIrony

Software random number generators do have their uses, particularly when debugging. Provided one uses the same seed, the 'random' sequence will be the same on each run. Thus, one can be assured that bugs that have revealed themselves have been fixed, because otherwise they will show themselves on the next run. Having a different sequence each time can lead to such bugs (and their ineffective fixes) not showing up again for months.

I am reminded that the Z80 has a refesh register, the value of which could be used to seed a random number generator. That effectively counted every refresh cycle from the moment the machine was switched on. I cannot remember if the modulus was 8 bit or 16 bit.

Michael