realbasic-nug
[Top] [All Lists]

Re: random seed generator?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: random seed generator?
From: Tim Jones <tjmac at tolisgroup dot com>
Date: Wed, 29 Nov 2006 15:05:59 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <21238198-7650-4FF8-A2A5-2CC3FCC0128B at comcast dot net>
On Nov 29, 2006, at 2:15 PM, Michael wrote:

Sorry if this brings peals of laughter, but I am trying to seed a random instance using this.

  const maxI = 2147483647
  const minus_maxI=-2147483648

  r.Seed=r.InRange(minus_maxI, maxI)

It seems a bit wrong to be using the random to generate it's own seed. I use something like this:

    Dim r As New Random
    Dim d As New Date

    r.Seed = d.TotalSeconds

I use the current time's "totalseconds" value as it always provides a different starting point. I'm sure there are better, more random mechanisms, but that's simple and works for most things I need randomization for.

Tim
--
Tim Jones
tjmac at tolisgroup dot com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>