On Wed, 01 Jul 1998, James Youngman wrote:
>You can also do this by reading one number from /dev/urandom and using
>it as a seed for rand().   In fact, that is probably a better approach
>than this chunk of code above.

One thing in particular I noticed early on - especially on DOS, is that
the rand() function isn't good enough for certain applications, for
instance, games.  It doesn't give enough resolution, and one gets the
feeling (at least I did) that one has played this exact hand, or 
scenario, before, too frequently.

Linux has random() and at one point I think it may have had rand32 or
rand64, or variants thereof. I can't find manual pages for the latter
here on Red Hat, so that's conjecture.

But random() (according to the manual pages) returns a number from
0 through 2^32-1, rather than from 0-2^16-1, as is the case with the
DOS rand(), and I suspect, the linux rand(), as well. On the other hand,
the manual pages suggest rand() uses the same algorithm as random(),
which may well be. But using a better range (and why not, since in Linux
we can use 4 byte ints) does make a difference.

--
------------------------------------------------------------------------
David E. Fox                 Tax              Thanks for letting me
[EMAIL PROTECTED]   the              change magnetic patterns
[EMAIL PROTECTED]      churches         on your hard disk.
-----------------------------------------------------------------------


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to