swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which generator for an 'unsigned long long' ?


From: Sven N. Thommesen
Subject: Re: Which generator for an 'unsigned long long' ?
Date: Wed, 31 May 2000 15:22:37 -0500

At 11:27 AM 5/28/2000 +0200, you wrote:
Which is the right generator to use and what's the exact syntax to draw an 'unsigned long long'  with min==0, with max== ULONG_LONG_MAX ?
Thanks,
      Fabio


Fabio,

as you will have discovered from the documentation, there is currently no generator that outputs 64-bit unsigned integers. All the implemented generators output a number in the range [0,unsignedMax] where unsignedMax *may* be 2^32-1 (as, for example, with the default generator MT19937).

You *could* fake it by filling a ulonglong with 2 draws from a 32-bit generator, but then the lower bits will always be functionally tied to the upper bits. Or, better, you could fill the 64-bit integer with 32-bit draws from two different generators (best: two generators of different type, to avoid having two generators of the same type get in sync). But I don't know what the statistical properties of such combo generators might be.

Of course, a generator that *did* output an unsigned 64-bit integer would be a beast to use from java: the automatic translation layer would promptly interpret this as a *signed* 64-bit integer, since java doesn't implement unsigned integers.

If you (or anyone else on the list!) have specific requests for things to add to the random library, please let me know.

Sven Thommesen
address@hidden
================================== Swarm-Support is for discussion of the technical details of the day to day usage of Swarm. For list administration needs (esp. [un]subscribing), please send a message to with "help" in the body of the message.
reply via email to

[Prev in Thread] Current Thread [Next in Thread]