delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/16/06:15:31

From: iverson AT cisco DOT com (Tim Iverson)
Subject: Re: about pseudo-random numbers
16 Jan 1998 06:15:31 -0800 :
Message-ID: <199801142118.NAA18660.cygnus.gnu-win32@stars.cisco.com>
References: <Pine DOT LNX DOT 3 DOT 96 DOT 980113114251 DOT 1703C-100000 AT pc66>
Mime-Version: 1.0
To: c9707059 AT cca DOT fc DOT up DOT pt (Valter EOR Santos)
Cc: gnu-win32 AT cygnus DOT com

You can use (random() % limit), but you need to beware of destroying some
of the properties of the sequence -- not all pseudo-random sequences retain
their various random properties after a modulus operation.

I recommend reading, Knuth's Seminumerical Algorithms (Art of Computer
Programming Vol 2.), for detailed info on pseudo-random sequences.

- Tim Iverson


+----------------
| Date: Tue, 13 Jan 1998 11:50:24 +0100 (MET)
| From: Valter EOR Santos <c9707059 AT cca DOT fc DOT up DOT pt>
| To: GNU-Win32 Mailing List <gnu-win32 AT cygnus DOT com>
| Subject: about pseudo-random numbers
| 
|   My question is if there is any way to make a limit in the random
| generation. In the Turbo Borland C++ i have the unit random(int limit)
| that produces numbers between 0 and limit. In the gnu, or other linux
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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