www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/20/19:55:53

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199606202347.AA025174448@relay1.geis.com>
Date: Thu, 20 Jun 96 23:32:00 UTC 0000
To: johan AT einstein DOT rug DOT ac DOT be
Cc: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Random numbers ...

Reply to message 1896793    from JOHAN AT EINSTEI on 06/17/96  9:55AM


>	int tmp;
>	tmp = random(3);
>
>With Borland, no problemo, it compiles, with DJGPP version 2, nope ...
>What is it man ?

As has been said recently on the list, the problem is with the definition
of random() on the two compilers.  DJGPP's random() doesn't take
any arguments, and returns a value from 0 to MAXINT.  You can
easily mask or mod the value to get a number from 0 to 2, e.g.:

tmp = random() % 3;

John

P.S.  Question for the gurus of the list:  Is this the same question that
everybody replied to a while back?  If so, why am I just seeing it now?

- Raw text -


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