home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / mac / programm / 18340 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.6 KB  |  37 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!alexia!cole
  3. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  4. Subject: Re: looking for a REALLY RaNdOM "RANDOM"
  5. References: <1djhjiINNhlc@mthvax.cs.miami.edu>
  6. Message-ID: <BxMI8x.MG9@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois at Urbana
  9. Date: Thu, 12 Nov 1992 21:55:44 GMT
  10. Keywords: random
  11. Lines: 24
  12.  
  13. In <1djhjiINNhlc@mthvax.cs.miami.edu> rsherman@mthvax.cs.miami.edu (Roby 
  14. Sherman) writes:
  15.  
  16. >Hello all.
  17.  
  18. >I'm looking for a pascal piece of code that illustrates a really nice
  19. >random number generation.
  20.  
  21. >I'm working on an INIT that needs a few random numbers and at boot time,
  22. >Apple's RANDOM function seems to always retrurn the same old thing.
  23. >Any ideas?
  24.  
  25.  
  26. interesting thing to note... I suppose it is because the seed for it is 
  27. connected to how long the machine has been on? (i.e. in the same Mac, an INIT 
  28. will see the same thing every time)
  29.  
  30. If you want a way of generating different random numbers, the principle isn't 
  31. too tough. one quick psuedo-random number would just be some modulo math on the
  32. current date/time value. (for example, date mod 99 will give you a random 
  33. number between 0 and 98) Depending on how random you want the number, you can 
  34. get into some very fancy number twiddling to make things more erratic, but in 
  35. all likelihood, some modulo of the date/time (which is seconds since 12 am 
  36. 1/1/04) with an odd value should give you a useable base.
  37.