Xref: utzoo comp.sys.mac:55820 comp.sys.mac.programmer:15606 comp.sys.mac.misc:888 comp.sys.mac.system:665 Path: utzoo!attcan!uunet!nems!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) 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: <1990Jun28.170219.26023@eng.umd.edu> Date: 28 Jun 90 17:02:19 GMT References: <152@asacsg.mh.nl> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 23 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. >The random number I want must lis between 0 and 2097151. >I any of you out there has an idee how to do this, and willing to >share your idee, than you can make me verry happy. >I' am using Think Pascal for the Macintosh. >Greetings from Holland, >Koos Remigius. This may be naive, but why not rndnum,tmp:Longint; rndnum := Random; {get 16 bit random number from toolbox} rndnum := BitShift(rndnum, 16); tmp := Random; {get second 16 bit random number from toolbox} tmp := BitAnd(tmp,65535); {clear sign-extension} rndnum := abs(BitOr(tmp,rndnum)); {put the pieces together} rndnum := rndnum mod 2097152; -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu ][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?