Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Random number generator

Reply
Thread Tools

Random number generator

 
 
ciccio
Guest
Posts: n/a
 
      04-15-2008
Hi,

Maybe slightly off topic here, but what algorithm is used for the
implementation of rand() in <cstdlib> ?

Or if it is not standardized (which it should), does anybody know what
it is in g++?

Thanks
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-15-2008
ciccio wrote:
> Hi,
>
> Maybe slightly off topic here, but what algorithm is used for the
> implementation of rand() in <cstdlib> ?
>

See section 7.20.2.2 of the standard for a portable implementation.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-15-2008
Ian Collins wrote:
> ciccio wrote:
>> Hi,
>>
>> Maybe slightly off topic here, but what algorithm is used for the
>> implementation of rand() in <cstdlib> ?
>>

> See section 7.20.2.2 of the standard for a portable implementation.
>

The C99 standard that is.

--
Ian Collins.
 
Reply With Quote
 
Kai-Uwe Bux
Guest
Posts: n/a
 
      04-15-2008
ciccio wrote:

> Hi,
>
> Maybe slightly off topic here, but what algorithm is used for the
> implementation of rand() in <cstdlib> ?


Not specified by the standard.


> Or if it is not standardized (which it should),


C++0X will have <random> with standardized algorithms.


> does anybody know what it is in g++?


http://sources.redhat.com/cgi-bin/cv...?cvsroot=glibc

You want to look at rand.c and random.c.


Best

Kai-Uwe Bux
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      04-15-2008
On 15 avr, 10:57, Ian Collins <(E-Mail Removed)> wrote:
> ciccio wrote:


> > Maybe slightly off topic here, but what algorithm is used for the
> > implementation of rand() in <cstdlib> ?


> See section 7.20.2.2 of the standard for a portable implementation.


That's the C standard, of course. And it's known to be a very
poor generator.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Number Generator?? Kingsley Oteng VHDL 11 08-09-2010 10:00 AM
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Random number generator, generating 10 different numbers. Need Help. Wally ASP .Net 1 03-20-2006 12:19 AM
Random number/letter generator tshad ASP .Net 3 05-06-2005 06:15 PM



Advertisments