TIP: Click on subject to list as thread! ANSI
echo: nthelp
to: Geo.
from: Paul Ranson
date: 2004-12-07 14:11:18
subject: Re: c++ help

From: "Paul Ranson" 

That won't fix it, and in fact, will generally return 0...

If 'rand' is well designed then a series of calls of it should return a
series of numbers between 0 and RAND_MAX (32767 usually) where each number
occurs with the same frequency, given a long enough series. Obviously for
any given seed you get the same series each time you call srand. This isn't
bias, it's pseudo.

If you disregard any return from rand between 32760 and 32767 then I think
your distribution of 0-9 will be even. Happy to be proven wrong on this...

Paul

"Geo."  wrote in message
news:41b5aede$1{at}w3.nls.net...
> well a simple solution to that would be
>
> int n = (rand()/RAND_MAX)*99999
>
> That should give me a pretty random distribution of the right most 4
> characters, theoretically with no bias.
>
> Geo.(there actually is a bias dependent on the time you run the program)
>

--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)
SEEN-BY: 633/267 270 5030/786
@PATH: 379/45 1 396/45 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.