CVS update: php3/doc/functions

From: Date: Mon, 21 Dec 1998 20:45:21 +0000
Subject: CVS update: php3/doc/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-2973@lists.php.net to get a copy of this message
Date: Monday December 21, 1998 @ 15:45 Author: kk Update of /repository/php3/doc/functions In directory asf:/u/temp/cvs-serv5872/doc/functions Modified Files: math.sgml Log Message: The Mersenne Twister is a freely available random number generator with know periodic properties and distributions. It is also faster than your average random number generator. See http://www.math.keio.ac.jp/~matumoto/emt.html ("The Mersenne Twister Home Page") and http://www.scp.syr.edu/~marc/hawk/twister.html ("An optimized version of the Mersenne Twister") for more information. Index: php3/doc/functions/math.sgml diff -c php3/doc/functions/math.sgml:1.19 php3/doc/functions/math.sgml:1.20 *** php3/doc/functions/math.sgml:1.19 Tue Nov 17 04:53:54 1998 --- php3/doc/functions/math.sgml Mon Dec 21 15:45:21 1998 *************** *** 389,396 **** <function>rand</function>. <simpara> ! See also <function>rand</function> and ! <function>srand</function>. </refsect1> </refentry> --- 389,399 ---- <function>rand</function>. <simpara> ! See also <function>rand</function>, ! <function>srand</function> ! <function>mt_rand</function>, ! <function>mt_srand</function> and ! <function>mt_getrandmax</function>. </refsect1> </refentry> *************** *** 520,526 **** --- 523,629 ---- </refsect1> </refentry> + <refentry id="function.mt_rand"> + <refnamediv> + <refname>mt_rand</refname> + <refpurpose>generate a better random value</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>int <function>mt_rand</function></funcdef> + <paramdef><parameter><optional>int min</optional></parameter></paramdef> + <paramdef><parameter><optional>int max</optional></parameter></paramdef> + </funcsynopsis> + + <simpara> + Many random number generators of older libcs have dubious + or unknown characteristics. By default, PHP uses the + libc random number generator with the + <function>rand()</function> function. + <function>mt_rand()</function> function is a drop-in + replacement for this. It uses a random number generator + with known characteristics, the Mersenne Twister, which + will produce random numbers that should be suitable for + cryptographic purposes. + <simpara> + If called without the optional min,max arguments mt_rand() + returns a pseudo-random value between 0 and RAND_MAX. If + you want a random number between 5 and 15 (inclusive), for + example, use mt_rand(5,15). + <simpara> + Remember to seed the random number generator before use with + <function>mt_srand</function>. + <simpara> + See also <function>mt_srand</function>, + <function>mt_getrandmax</function>, + <function>srand</function>, + <function>rand</function> and + <function>getrandmax</function>. + </refsect1> + </refentry> + + <refentry id="function.mt_srand"> + <refnamediv> + <refname>mt_srand</refname> + <refpurpose>seed the better random number generator</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>void <function>mt_srand</function></funcdef> + <paramdef>int <parameter>seed</parameter></paramdef> + </funcsynopsis> + + <para> + Seeds the random number generator with + <parameter>seed</parameter>. + <informalexample> + <programlisting> + // seed with microseconds since last "whole" second + mt_srand((double)microtime()*1000000); + $randval = mt_rand(); + </programlisting> + </informalexample> + + <simpara> + See also <function>mt_rand</function>, + <function>mt_getrandmax</function>, + <function>srand</function>, + <function>rand</function> and + <function>getrandmax</function>. + + </refsect1> + </refentry> + + <refentry id="function.mt_getrandmax"> + <refnamediv> + <refname>mt_getrandmax</refname> + <refpurpose>show largest possible random value</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>int <function>mt_getrandmax</function></funcdef> + <paramdef>void </paramdef> + </funcsynopsis> + + <simpara> + Returns the maximum value that can be returned by a call to + <function>mt_rand</function>. + + <simpara> + See also <function>mt_rand</function>, + <function>mt_srand</function> + <function>rand</function>, + <function>srand</function> and + <function>getrandmax</function>. + + </refsect1> + </refentry> + + <refentry id="function.number-format"> <refnamediv> <refname>number_format</refname> *************** *** 646,651 **** --- 749,760 ---- <simpara> Remember to seed the random number generator before use with <function>srand</function>. + <simpara> + See also <function>srand</function>, + <function>getrandmax</function>, + <function>mt_rand</function>, + <function>mt_srand</function> and + <function>mt_getrandmax</function>. </refsect1> </refentry> *************** *** 746,752 **** </informalexample> <simpara> ! See also <function>rand</function> and <function>getrandmax</function>. </refsect1> </refentry> --- 855,865 ---- </informalexample> <simpara> ! See also <function>rand</function>, ! <function>getrandmax</function>, ! <function>mt_rand</function>, ! <function>mt_srand</function> and ! <function>mt_getrandmax</function>. </refsect1> </refentry> -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2973) next »