Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Java's RNG (using seeds) platform-independent?

Apologies in advance for asking a (seemingly obvious) question. I haven't found an answer online, so I figured I'd ask:

Is Java's Util.Random platform-independent?

For Example, is new Random(50) going to produce the exact same sequence of random numbers in both *nix and Windows systems?

like image 469
AlexeyMK Avatar asked Jan 13 '10 22:01

AlexeyMK


1 Answers

From the docs:

If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers. In order to guarantee this property, particular algorithms are specified for the class Random. Java implementations must use all the algorithms shown here for the class Random, for the sake of absolute portability of Java code.

like image 136
Anon. Avatar answered Oct 20 '22 00:10

Anon.