<div dir="ltr">Hi all (and TUHS),<div><br></div><div>The Third Edition rand(III) page [1] ends with</div><div><br>WARNING  The author of this routine has been writing </div><div>    random-number generators for many years and has </div><div>    never been known to write one that worked.</div><div><br></div><div>My understanding is that Ken wrote the rand implementation.</div><div>But I'm curious about the origin of this warning. <br>I had assumed that Ken wrote it as a combination warning+joke,</div><div>but Rob suggested that to him it didn't sound like Ken and</div><div>perhaps Doug or Dennis had written it. Does anyone remember?</div><div><br></div><div>Separately, I am trying to find out what the very first</div><div>Unix rand implementation was. In the TUHS archives,</div><div>the incomplete V2 sources contain a reference to srand</div><div>in cmd/bas0.s [2], but there is no definition in the tree.</div><div>The V3 man pages list it, but as far as I can tell full </div><div>library sources do not appear in the TUHS archives</div><div>until the V6 snapshot. The V6 rand [3] is:<br></div><div><br></div><div>rand:<br>    mov   r1,-(sp)<br>    mov    ranx,r1<br>    mpy     $13077.,r1<br>    add  $6925.,r1<br>    mov   r1,r0<br>    mov       r0,ranx<br>    bic     $100000,r0<br>    mov  (sp)+,r1<br>    rts     pc<br></div><div><br></div><div>Perhaps this is the original rand as well? It is hard to imagine</div><div>a much simpler one, other than perhaps removing the addition,</div><div>but doing so would create a sequence of only odd numbers.</div><div>From the man page description it sounds like this has to be the</div><div>original generator, perhaps with different constants.</div><div><br></div><div>Thanks!</div><div><br>Best,</div><div>Russ</div><div><br></div><div>[1] <a href="https://github.com/dspinellis/unix-history-repo/blob/Research-V3/man/man3/rand.3">https://github.com/dspinellis/unix-history-repo/blob/Research-V3/man/man3/rand.3</a></div><div>[2] <a href="https://github.com/dspinellis/unix-history-repo/blob/Research-V2/cmd/bas0.s">https://github.com/dspinellis/unix-history-repo/blob/Research-V2/cmd/bas0.s</a></div><div>[3] <a href="https://github.com/dspinellis/unix-history-repo/blob/Research-V6/usr/source/s3/rand.s">https://github.com/dspinellis/unix-history-repo/blob/Research-V6/usr/source/s3/rand.s</a></div><div><br></div><div><br></div><div><br></div></div>