The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Ken Thompson <kenbob@gmail.com>,
	Douglas McIlroy <douglas.mcilroy@dartmouth.edu>,
	"Rob 'Commander' Pike" <robpike@gmail.com>
Cc: tuhs@tuhs.org
Subject: [TUHS] Re: early unix rand
Date: Tue, 12 Mar 2024 14:08:26 -0400	[thread overview]
Message-ID: <CADSkJJXob-OMbJ0N12G+97yF6v1u2yC7ti9YP8BtnUEX2DcjmA@mail.gmail.com> (raw)
In-Reply-To: <CADSkJJWc_dVMvN+HijKGWwKVTppzMGF_m9mfW4yRxE_6AnhF4g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 428 bytes --]

  reply	other threads:[~2024-03-12 18:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 12:55 [TUHS] " Russ Cox
2024-03-12 18:08 ` Russ Cox [this message]
2024-03-12 23:05 ` [TUHS] " Jonathan Gray
2024-03-13  1:09   ` ron minnich
2024-03-13 16:41     ` ron minnich
2024-03-13 17:17       ` ron minnich
2024-03-13 20:25         ` Rob Pike
2024-03-13 20:34           ` Clem Cole
2024-03-14 19:24             ` Dave Horsfall
2024-03-12 14:37 [TUHS] " Douglas McIlroy
2024-03-12 16:23 ` [TUHS] " Paul Winalski
2024-03-13  1:22   ` Russ Cox
2024-03-12 16:32 ` Ken Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADSkJJXob-OMbJ0N12G+97yF6v1u2yC7ti9YP8BtnUEX2DcjmA@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=douglas.mcilroy@dartmouth.edu \
    --cc=kenbob@gmail.com \
    --cc=robpike@gmail.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).