www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/25/03:22:40

Date: Tue, 25 Feb 1997 10:16:44 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Erik Max Francis <max AT alcyone DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Error??
In-Reply-To: <33127BBC.48E0ABC7@alcyone.com>
Message-ID: <Pine.SUN.3.91.970225101353.6546O-100000@is>
MIME-Version: 1.0

On Mon, 24 Feb 1997, Erik Max Francis wrote:

> random is a non-standard function.  Thus you're not guaranteed that it will
> have the same arguments on different compilers.

AFAIK, `random' is POSIX.  So at least POSIX-compliant compilers will 
have it.  Borland, of course, isn't one of them.

> Use rand (which is not as good a pseudorandom number generator in DJGPP),
> like this:
> 
>     roll = rand()%6 + rand()%6 + rand()%6 + 3;

A known problem with `rand' that using the lower bits of the value
returned by it could get you very bad results.  OTOH, `random' is
specifically documented to have all of its bits random. 

- Raw text -


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