Article View: comp.sys.mac
Article #12864Re: Random number Generator wanted.
From: Matthew T. Russotto
Date: Thu, 28 Jun 1990 17:02
Date: Thu, 28 Jun 1990 17:02
23 lines
1413 bytes
1413 bytes
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?
Technical Details
Message-ID:
<1990Jun28.170219.26023@eng.umd.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!nems!mimsy!mojo!russottoReferences:
<152@asacsg.mh.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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