Name: rlT66838 Date: 08/09/99
java.util.Random.nextBytes() stuffs bytes into an array by
grabbing random integers, then breaking the integers into
respective bytes and placing each into the array four at
a time. This comes form being too clever :-)
This is a BIG RANDOM NUMBER GENERATOR NO-NO.
One of the canonical rules of random number generators is
Thou Shalt Never Split A Random Number Into N Pieces And
Use Each One Independently. This places far too much
faith in the n-dimensional correctness of the Knuth
generator. See Numerical Recipies in C for more discussion
on why this is a really really bad idea.
I discovered this bug while doing testing for a replacement
random number generator based on the Mersenne Twister (a FAR
superior random number generator than the Knuth one the JDK is
using, and faster too -- if you want it let me know).
(Review ID: 93712)
======================================================================
java.util.Random.nextBytes() stuffs bytes into an array by
grabbing random integers, then breaking the integers into
respective bytes and placing each into the array four at
a time. This comes form being too clever :-)
This is a BIG RANDOM NUMBER GENERATOR NO-NO.
One of the canonical rules of random number generators is
Thou Shalt Never Split A Random Number Into N Pieces And
Use Each One Independently. This places far too much
faith in the n-dimensional correctness of the Knuth
generator. See Numerical Recipies in C for more discussion
on why this is a really really bad idea.
I discovered this bug while doing testing for a replacement
random number generator based on the Mersenne Twister (a FAR
superior random number generator than the Knuth one the JDK is
using, and faster too -- if you want it let me know).
(Review ID: 93712)
======================================================================