http://www.tienza.es/crux/src/www.jwz.org/xscreensaver/xscreensaver-5.06.tar.gz
[xscreensaver] / utils / yarandom.c
index 63958e24700b35bdff62cda8af9a7f34d50cdb26..cc38895e5130bc2a7a625def971bd6e98cd8c338 100644 (file)
@@ -1,13 +1,23 @@
 /* yarandom.c -- Yet Another Random Number Generator.
+ * Copyright (c) 1997, 1998, 2003 by Jamie Zawinski <jwz@jwz.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  No representations are made about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ */
 
-   The unportable mess that is rand(), random(), drand48() and friends led me
+/* The unportable mess that is rand(), random(), drand48() and friends led me
    to ask Phil Karlton <karlton@netscape.com> what the Right Thing to Do was.
    He responded with this.  It is non-cryptographically secure, reasonably
    random (more so than anything that is in any C library), and very fast.
 
    I don't understand how it works at all, but he says "look at Knuth,
    Vol. 2 (original edition), page 26, Algorithm A.  In this case n=55,
-   k=20 and m=2^32."
+   k=24 and m=2^32."
 
    So there you have it.
 
@@ -51,6 +61,7 @@
 #include <sys/time.h> /* for gettimeofday() */
 
 #include "yarandom.h"
+# undef ya_rand_init
 
 
 /* The following 'random' numbers are taken from CRC, 18th Edition, page 622.
@@ -110,5 +121,5 @@ ya_rand_init(unsigned int seed)
     }
 
   i1 = a[0] % VectorSize;
-  i2 = (i1 + 024) % VectorSize;
+  i2 = (i1 + 24) % VectorSize;
 }