delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/02/03:50:43

From: Damian Yerrick <DELCAPSyerricde AT pineight DOT 8mSOFTWARE DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: rand and random
Organization: Pin Eight Software <http://yerricde.tripod.com/binaries/>
Message-ID: <xIgeOAnzj2KaFWlGUNnv=obD+Vkp@4ax.com>
References: <s1n73iu5iqi71 AT corp DOT supernews DOT com> <p6obOB+BRMP7QeUGn1Z+l2JBPBVt AT 4ax DOT com> <Pine DOT SUN DOT 3 DOT 91 DOT 991031100828 DOT 2988f-100000 AT is>
X-Newsreader: Forte Agent 1.6/32.525
MIME-Version: 1.0
Lines: 27
X-Trace: /K49oFxE8MoBjfDLUiwoE766Lp9hCIUVt46TDvxZ0/JSt95EOyXH+rTDcgz1gRRsfgHRhGTyUas9!S3zKvZAxcE8g5B0xmNZyJUL5u41JukzLObH8d8ZDodz9cs9jHapupNXWHRWXN2+0Bg==
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Tue, 02 Nov 1999 06:51:04 GMT
Distribution: world
Date: Tue, 02 Nov 1999 06:51:05 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 31 Oct 1999 10:08:42 +0200,
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> On Sun, 31 Oct 1999, Damian Yerrick wrote:
> 
> > rand() will give a number between 0 and 32,767.
> 
> Not true; please try to check your advice before posting.
> 
> `rand' returns a random integer between 0 and RAND_MAX.  The latter is
> defined on stdlib.h, and is much larger than 32K.

I thought some C standard defined rand() as

#define RAND_MAX 0x7fff
int rand(void)
{
  mySeed = (mySeed * 1103515245) + 12345;
  return (mySeed & 0x7fff0000) >> 16;
}

Maybe I misunderstood the standard, or maybe the translation (into
plain English) was wrong... :-(

--
Damian Yerrick
Visit my web site: http://yerricde.spedia.net/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019