please dont rip this site

Language Ccpp Cref Man Rand.htm

 <TITLE>rand</TITLE>
<body bgcolor="#ffffcc">
<hr>
<pre>



<h3>RAND(3)             Linux Programmer's Manual             RAND(3)
</h3>

<h3>NAME
</h3>       rand, srand - random number generator.

<h3>SYNOPSIS
</h3>       #include &lt;stdlib.h&gt;

       int rand(void);

       void srand(unsigned int seed);

<h3>DESCRIPTION
</h3>       The   rand()  function  returns  a  pseudo-random  integer
       between 0 and RAND_MAX.

       The srand() function sets its argument as the seed  for  a
       new  sequence  of pseudo-random integers to be returned by
       rand().  These sequences are repeatable by calling srand()
       with the same seed value.

       If no seed value is provided, the rand() function is auto-
       matically seeded with a value of 1.

<h3>RETURN VALUE
</h3>       The  rand()  function  returns  a  value  between  0   and
       RAND_MAX.  The srand() returns no value.

<h3>NOTES
</h3>       The  versions of rand() and srand() in the Linux C Library
       use the same random number generator as random() and sran-
       dom(),  so the lower-order bits should be as random as the
       higher-order bits.  However, on older  rand()  implementa-
       tions,  the lower-order bits are much less random than the
       higher-order bits.

       In Numerical Recipes in C: The Art of Scientific Computing
       (William  H.  Press, Brian P. Flannery, Saul A. Teukolsky,
       William T.  Vetterling;  New  York:  Cambridge  University
       Press,  1990 (1st ed, p. 207)), the following comments are
       made:
              "If you want to generate a random integer between 1
              and 10, you should always do it by

                     j=1+(int) (10.0*rand()/(RAND_MAX+1.0));

              and never by anything resembling

                     j=1+((int) (1000000.0*rand()) % 10);

              (which uses lower-order bits)."

       Random-number  generation is a complex topic.  The Numeri-
       cal Recipes in C book (see reference  above)  provides  an
       excellent discussion of practical random-number generation
       issues in Chapter 7 (Random Numbers).



<h3>GNU                        18 May 1995                          1
</h3>




<h3>RAND(3)             Linux Programmer's Manual             RAND(3)
</h3>

       For a more theoretical discussion which also  covers  many
       practical  issues  in  depth, please see Chapter 3 (Random
       Numbers) in Donald E. Knuth's The Art of Computer Program-
       ming,  volume 2 (Seminumerical Algorithms), 2nd ed.; Read-
       ing,  Massachusetts:  Addison-Wesley  Publishing  Company,
       1981.

<h3>CONFORMING TO
</h3>       SVID 3, BSD 4.3, ISO 9899

</pre>
<hr>
<h3>SEE ALSO
</h3><p>
<a href=random.htm>random</a>, 
<a href=srandom.htm>srandom</a>, 
<a href=initstate.htm>initstate</a>, 
<a href=setstate.htm>setstate</a>, 
<pre>













































<h3>GNU                        18 May 1995                          2
</h3>


</pre>
<P>
<hr>
<p>
<center>
<table border=2 width=80%>
<tr align=center>
<td width=25%>
<a href=../index.htm>Top</a>
</td><td width=25%>
<a href=../master_index.html>Master Index</a>
</td><td width=25%>
<a href=../SYNTAX/keywords.html>Keywords</a>
</td><td width=25%>
<a href=../FUNCTIONS/index.htm>Functions</a>
</td>
</tr>
</table>
</center>
<p>
<hr>

This manual page was brought to you by <i>mjl_man V-2.0</i>


file: /Techref/language/ccpp/cref/MAN/rand.htm, 3KB, , updated: 2003/3/20 09:39, local time: 2024/12/28 10:59,
TOP NEW HELP FIND: 
3.15.142.42:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/techref/language/ccpp/cref/MAN/rand.htm"> rand</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?