Discussion:
Research of informations about java.util.Random
Damien W
2014-12-18 08:10:25 UTC
Permalink
Hello,

I found on Javadoc (java.util.Random) the linear congruential generator
formula which is:

seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)

I'd like to know why these numbers were chosen (0x5DEECE66D, 0xB), why
are they in hexadecimal and why is there a bit-to-bit comparison.

Best regards,

Damien Wojtowicz
Martin Buchholz
2014-12-18 18:00:13 UTC
Permalink
LMGTFY: Donald Knuth, The Art of Computer Programming, Volume 3, Section 3.2.1.)
Post by Damien W
Hello,
I found on Javadoc (java.util.Random) the linear congruential generator
seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)
I'd like to know why these numbers were chosen (0x5DEECE66D, 0xB), why
are they in hexadecimal and why is there a bit-to-bit comparison.
Best regards,
Damien Wojtowicz
Loading...