commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <>
Subject [Math] JDK "Random" and "BitsStreamGenerator"
Date Tue, 26 Jan 2016 00:13:15 GMT

In CM, a base class "BitsStreamGenerator" contains methods for
generating various primitive types from a bit source (to be
implemented by subclasses by overriding the "next(int bits)"
For example, to get a random "long" value, the following code
is called:
     public long nextLong() {
         final long high  = ((long) next(32)) << 32;
         final long  low  = (next(32)) & 0xffffffffL;
         return high | low;

If the bit source were provided by the JDK's "Random" class,
is it assumed that the "long" value generated by the above
code will always be equal to the "long" value generated by
the call to JDK's "Random" class?

In other words, how "standard" are the default implementations
of the methods defined in "BitsStreamGenerator"?

And what are the compatibility requirements with respect to
reproducibility of the sequences (between releases of the


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message