File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Random Numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Random Numbers" Watch "Random Numbers" New topic
Author

Random Numbers

Jeff Smith
Ranch Hand

Joined: May 04, 2001
Posts: 50
Hi,

I'm wondering if there's anyway to get Java's random number generator to generate the same sequence of numbers as C's srand and rand? That is, if I were to call C's srand() with a seed of 100 and create a new Random object in java with a seed of 100 and then use, in C, rand() and, in Java, nextInt() how can I get the same sequence of numbers from Java as I would from C? Is it even possible?

For those wondering, I'm trying to create a modified version of FreeCell and I want to have the games be the same as in the Microsoft version, which uses the random number generator in C to generate the card order in the games.

Thanks,
Jeff
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I would guess that there isn't a single c-random-implementation, but different ones from borland, intel, gnu, ...
Some of them aren't open-source, but chances aren't bad, that the algorithm is documented, since a lot of users are interested.

So I guess you have to find out, which library is/ was used with your freecell, and reimplement it with java on your own.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Random Numbers
 
Similar Threads
Random Number
Better way of random number generation using multiple threads
A thorny problem about class Random
random numbers
how to generate random numbers ? Random class always generate same number....