ssb             Wed Sep 19 20:50:08 2001 EDT

  Modified files:              
    /phpdoc/en/functions        math.xml 
  Log:
  * make better seeds in mt_srand/srand examples
  
  
Index: phpdoc/en/functions/math.xml
diff -u phpdoc/en/functions/math.xml:1.51 phpdoc/en/functions/math.xml:1.52
--- phpdoc/en/functions/math.xml:1.51   Sat Sep  1 10:54:08 2001
+++ phpdoc/en/functions/math.xml        Wed Sep 19 20:50:08 2001
@@ -1,5 +1,5 @@
 <?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.51 $ -->
+<!-- $Revision: 1.52 $ -->
  <reference id="ref.math">
   <title>Mathematical Functions</title>
   <titleabbrev>Math</titleabbrev>
@@ -794,8 +794,12 @@
      <parameter>seed</parameter>.
      <informalexample>
       <programlisting role="php">
-// seed with microseconds since last "whole" second
-mt_srand ((float) microtime() * 1000000);
+// seed with microseconds
+function make_seed() {
+    list($usec,$sec) = explode(" ", microtime());
+    return ((double)$sec+(double)$usec) * 100000;
+}
+mt_srand(make_seed());
 $randval = mt_rand();
       </programlisting>
      </informalexample>
@@ -1223,8 +1227,12 @@
      <parameter>seed</parameter>.
      <informalexample>
       <programlisting role="php">
-// seed with microseconds since last "whole" second
-srand ((float) microtime() * 1000000);
+// seed with microseconds
+function make_seed() {
+    list($usec,$sec) = explode(" ", microtime());
+    return ((double)$sec+(double)$usec) * 100000;
+}
+srand(make_seed());
 $randval = rand();
       </programlisting>
      </informalexample>


Reply via email to