[mercury-users] Converting time_t to int using common library?

Peter Schachte schachte at csse.unimelb.edu.au
Thu Feb 15 10:07:40 AEDT 2007


Julian Fondren wrote:
> On 2/13/07, Peter Schachte <schachte at csse.unimelb.edu.au> wrote:
>> One problem with this is that if you call it twice in rapid
>> succession, it
>> will
>> probably give you the same random supply.  It would probably be better
>> for
>> subsequent calls to this to us some function (e.g., xor) of the time
>> and the
>> previously generated seed.

> However, xor doesn't work very well for this: given a cached seed S, the
> second
> of two functionally simultaneous calls to random.init will return S.  I
> think
> + would do better.

+ is good, too, although it throws away 1 bit of entropy on the carry out.

xor would be OK, too, as long as the creation of a fresh var supply also runs
the random number generator once, so that the new seed is an unpredictable
function of the previous seed and the date/time.

-- 
Peter Schachte              Ultimately, there's no such thing as
schachte at cs.mu.OZ.AU        "organizational behavior"; it's all behavior of
www.cs.mu.oz.au/~schachte/  the people in the organization.
Phone: +61 3 8344 1338          -- Stephen Covey, et al.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list