[TUHS] early unix rand
Russ Cox
rsc at swtch.com
Wed Mar 13 04:08:26 AEST 2024
Someone asked off-list for a C translation of the PDP-11 assembly code. I
believe the equivalent modern C would be:
unsigned int ranx;
void
srand(unsigned int seed)
{
ranx = seed;
}
int
rand(void)
{
ranx = 13077*ranx + 6925;
return ranx & 32767;
}
Best,
Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20240312/03b3fbfd/attachment.htm>
More information about the TUHS
mailing list