www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/25/13:18:47

From: "Pieter van Ginkel" <pginkel AT westbrabant DOT net>
To: <saf AT magic DOT fr>, <djgpp AT delorie DOT com>
Subject: Re: How to limit a random() with DJGPP ?
Date: Wed, 25 Feb 1998 15:29:56 +0100
Message-ID: <01bd41f9$d7ef7aa0$cd2f86c2@pieter>
MIME-Version: 1.0

What I always do is this

#define Random(x) (random() % x)
and then just use Random. This works quite well. The only thing with this is
that you can't get random numbers bigger that MAXINT. I think rand() does
this but you should find that out yourself.
If you want to have a random function that gives a floatingpoint result,
usae something like this.

#define FPRandom() (random() / (double)MAXINT)

Foxe,
home.westbrabant.net/~pginkel
(Is going to be better if I finally get the time...)


-----Oorspronkelijk bericht-----
Van: Stephan <saf AT magic DOT fr>
Nieuwsgroepen: comp.os.msdos.djgpp
Aan: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Datum: woensdag 25 februari 1998 1:13
Onderwerp: Re: How to limit a random() with DJGPP ?


>i have put a randomize example on my page under tutorials.
>go to:  http://www.mygale.org/03/mine/
>--
>****************************************
>*         THE DJGPP MINE !!!           *
>* FREE SOURCE CODES, FAQ, INFOS, LINKS *
>****************************************
>*   http://www.mygale.org/03/mine/     *
>****************************************
>*           24h/24h 7/7days            *
>****************************************

- Raw text -


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