🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #12917

Re: Random number Generator wanted.

#12917
From: Marc T. Kaufman
Date: Sat, 30 Jun 1990 17:09
42 lines
2287 bytes
In article <1990Jun29.020739.9146@Neon.Stanford.EDU> kaufman@Neon.Stanford.EDU (Marc T. Kaufman) writes:
>In article <152@asacsg.mh.nl> kr@asacsg.mh.nl (Koos Remigius) writes:
->What I need is a random number generator that gives me a random LongInt back.

and I write back:
>If you have a Mac II, the following might help.:
[some assembly code for the Mac deleted]

I recently received the following mail:

"You may like to know that the Random function in the Mac ROM *is*
 the same as the "minimal std" function published in the CACM paper.
 It's just that it truncates the computed result to 16-bits. However,
 you can get at the 32-bit result by accessing the QD global "RandSeed".
 This works because Random uses the linear congruential method which is
 iterative, and saves the next computed random no in the sequence in
 RandSeed. Ie do something like (in C)

  (void) Random();  /* ignore 16 bit result */
  theValue = qd.randSeed; /* use 32-bit result */

 In Pascal, just assign the unwanted 16-bit result to a dummy.
 
 I compared 10000 rn's from a C version of the CACM rn generator with
 that generated by the ROM's Random() function, and they were identical.

 Best regards
 
 Sak Wathanasin
 Network Analysis Limited
 uucp:	...!ukc!nan!sw
 other:	sw@network-analysis-ltd.co.uk
 phone:  (+44) 203 419996
 telex:  9312130355 (SW G)
 snail:  178 Wainbody Ave South, Coventry CV3 6BX, UK

I thank Sak for this info.  I am not sure just which Macs this applies to --
probably the ci and fx, certainly not the SE.  Can someone from Apple tell us
when the algorithm changed, and is it part of a system patch so all Macs can
benefit from it?

Marc Kaufman (kaufman@Neon.stanford.edu)
Technical Details
Message-ID: <1990Jun30.170949.1426@Neon.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!shelby!neon!kaufman
References: <152@asacsg.mh.nl> <1990Jun29.020739.9146@Neon.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!shelby!neon!kaufman
From: kaufman@Neon.Stanford.EDU (Marc T. Kaufman)
Newsgroups: comp.sys.mac,comp.sys.mac.programmer,comp.sys.mac.misc,comp.sys.mac.system
Subject: Re: Random number Generator wanted.
Keywords: Random number
Message-ID: <1990Jun30.170949.1426@Neon.Stanford.EDU>
Date: 30 Jun 90 17:09:49 GMT
References: <152@asacsg.mh.nl> <1990Jun29.020739.9146@Neon.Stanford.EDU>
Organization: Computer Science Department, Stanford University
Lines: 42