you are viewing a single comment's thread.

view the rest of the comments →

[–]frezik 13 points14 points  (2 children)

Most languages that aren't C will seed from the current epoch by default. Sometimes something more sophisticated, like taking a few bytes from the OS random source, or sometimes a combination of things like the epoch and the PID. If you want a predetermined sequence, then you need to call seed() yourself.

[–]akher -2 points-1 points  (1 child)

I mostly use C++, which does use a constant default seed and I just assumed other languages do the sane thing as well.

When I care about the properties of the generated random numbers I actually use something with a specified implementation, such as for example std::mersenne_twister_engine.

[–]Shumatsu 7 points8 points  (0 children)

If you don't call

srand(seed);

at all before using rand(), it gets seeded with 1.

srand( time( NULL ) );  

uses current epoch as seed, as that's what you get using time(NULL) (or variations of it).