RE: [EXTERNAL] Re: rand is not ISO C compliant in Cygwin

"Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <[email protected]>
Newsgroups gmane.comp.lib.newlib,gmane.os.cygwin
Message-ID <DM8PR09MB7095FD4287584FC53200831CA5B3A@DM8PR09MB7095.namprd09.prod.outlook.com>
IMHO:

>   2. A different sequence

The word "different" in this context is ambiguous: is it "unrelated" as a generator, or is it "not the same" sequence of the actual numbers?

> I read this as the newlib technique being one way of correctly implementing rand/srand, no?

If the first, then yes; but if the second, then no.

The problem with the first approach is, however, is the inability to adequately randomize your code (e.g. for testing).

You call srand() in the main() thread, and then spawn threads thinking they will inherit the randomization; but in fact, they all start off the same number sequence, regardless.

Anton Lavrentiev
Contractor NIH/NLM/NCBI
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.