I have been using this in Java and I know what it produces:
Random r = new Random();
double mynum = r.nextDouble();
Whereas, I found this code in C++ which I wanted to use in Java:
srand(time(NULL));
double mynum = (double)rand() / RAND_MAX;
Are these both equal?
If no, then what would be the equivalent java code?
where equivalent means produce a similar sequence of numbers? And my scientific computation will not be affected by this conversion.
I was assuming both as the same thing, not sure...
Aucun commentaire:
Enregistrer un commentaire