[erlang-bugs] Bug in random seed (definition?) and random:uniform_s/2

Heinz Nikolaus Gies heinz@REDACTED
Thu Mar 10 21:59:32 CET 2016


This might not be critical any more since seed is deprecated but I encountered a problem with random today when passing in hand crafted seeds.

The definition of a seed is: {integer(), integer(), integer()}

The seed was generated by the method suggested in random:seed:
{erlang:phash2([node()]),
 erlang:monotonic_time(),
 erlang:unique_integer()}
This resulted in the seed:

{128631525,-576302453291645741,-576460752303421854}

That seed is valid based on the type specification of seed.

Now entered random:uniform_s/2, by specification it returns a value 1 <= N <= (passed argument) BUT it doesn’t with this seed:

random:uniform_s(10, {128631525,-576302453291645741,-576460752303421854}).
{-1,{23048,-115,-29427}}


Yes I know that  constructing and passing a seed like this is evil,  please don’t get hung on that, it is not my code it’s code I am debugging - I fully agree that it probably should be changed to rand and be done with it, still it looks is a bug.

Cheers,
Heinz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20160310/95bb3930/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20160310/95bb3930/attachment.bin>


More information about the erlang-bugs mailing list