Re: 32-bit random numbers

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> return remainder(x, floor(n)) + 1

There might be a bug in here: you want a random number between 1 and n, so n
should also be a possible value.
If x is n, remainder(x, floor(n)) will return 0 instead of n: n can never be the
result of remainder(x, floor(n)).
I think you can solve this by changing it to: remainder(x + 1, floor(n)).

--
tommy online: http://users.pandora.be/tommycarlier
Euphoria Message Board: http://uboard.proboards32.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu