# HG changeset patch # User jwe # Date 790533822 0 # Node ID 705c8ac6bcd42c65c3f9afea365d845966ed1d6a # Parent e34efb49a2290ed39eda712875810173ad1217bb [project @ 1995-01-19 16:43:42 by jwe] diff --git a/src/rand.cc b/src/rand.cc --- a/src/rand.cc +++ b/src/rand.cc @@ -123,7 +123,10 @@ if (! initialized) { // Make the random number generator give us a different sequence every -// time we start octave unless we specifically set the seed. +// time we start octave unless we specifically set the seed. The +// technique used below will cycle monthly, but it it does seem to +// work ok to give fairly different seeds each time Octave starts. + #if 0 int s0 = 1234567890; int s1 = 123456789; @@ -134,8 +137,12 @@ time (&now); tm = localtime (&now); - int s0 = tm->tm_min * 60 + tm->tm_sec; - int s1 = (tm->tm_mday - 1) * 24 * 3600 + tm->tm_hour * 3600 + s0; + int hour = tm->tm_hour + 1; + int minute = tm->tm_min + 1; + int second = tm->tm_sec + 1; + + int s0 = tm->tm_mday * hour * minute * second; + int s1 = hour * minute * second; #endif s0 = force_to_fit_range (s0, 1, 2147483563); s1 = force_to_fit_range (s1, 1, 2147483399);