home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / hp48 / 4497 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.8 KB

  1. Path: sparky!uunet!usc!rpi!uwm.edu!ogicse!news.u.washington.edu!nntp.uoregon.edu!nntp.uoregon.edu!stevev
  2. From: stevev@miser.uoregon.edu (Steve VanDevender)
  3. Newsgroups: comp.sys.hp48
  4. Subject: Re: HP's RAND algorithm
  5. Message-ID: <STEVEV.92Sep5145750@miser.uoregon.edu>
  6. Date: 5 Sep 92 21:57:50 GMT
  7. Article-I.D.: miser.STEVEV.92Sep5145750
  8. References: <1992Sep4.183731.130@news.uiowa.edu>
  9. Sender: news@nntp.uoregon.edu
  10. Organization: University of Oregon Chemistry Stores
  11. Lines: 28
  12. In-Reply-To: jollie@zambini.cs.uiowa.edu's message of Fri, 4 Sep 1992 18:37:31 GMT
  13.  
  14.  
  15. In article <1992Sep4.183731.130@news.uiowa.edu> jollie@zambini.cs.uiowa.edu (Jeffrey C. Ollie) writes:
  16.  
  17.    I just got my 48SX, and I love it! But, I was wondering what algorithm
  18.    HP used for the random number generator. I'm hoping that it is a
  19.    prime modulus multiplicative linear conguential generator (I'm not
  20.    making this up) with a=16807 and m=2^31 - 1. I've written one of my own,
  21.    but would prefer to use the built in RAND.
  22.  
  23. The HP 48 uses a multiplicative linear congruential generator (I
  24. know you're not making it up) but not the particular one you
  25. speak of.  It uses the formula
  26.  
  27. R(n+1) = R(n) * 2851130928467 (mod 10^15)
  28.  
  29. to generate a 15 decimal digit internal seed.  The random number
  30. returned is R(n+1) / 10^15 rounded to 12 decimal digits.
  31.  
  32. The random number seed R(n) is stored in BCD at #706A4.  If the
  33. seed is 0, then the seed is reset to 999500333083533.
  34.  
  35. This information was obtained by disassembling the system RPL
  36. routine %RAN, a primitive code object at #2AFC2.
  37. --
  38. Steve VanDevender     stevev@greylady.uoregon.edu
  39. "Bipedalism--an unrecognized disease affecting over 99% of the population.
  40. Symptoms include lack of traffic sense, slow rate of travel, and the
  41. classic, easily recognized behavior known as walking."
  42.