occupy a method made in migrating Visual Fox Pro emigrarlo to C #, the problem I have is how to know if the method in Visual Fox Pro:
Rand(intValue)
method is equal to dotNet:
Random r = new Random (intValue);
r.Next return ();
assuming that intValue = 971 the result generated in dotNET is 2027119, but I need to be equal to that return FoxPro.
Primary question:
how I can make sure I get the same result?
Secondary question:
Do you know of any online tool fox pro to prove that this method gives me result Rand ()?
Primary question: how I can make sure I get the same result?
So you want to guarantee that you get the same result... from two different random number generators... right.
intValue
in your FoxPro example is a seed value. Why in the world would you need to guarantee that the two libraries use the same random number generator (HINT: They almost certainly do not). Seriously, if you are after random numbers, what difference does it make?
If you want a known series of numbers then you really don't want a random number at all. This boggles my mind. If your code is setup to expect a certain string of values from a random number generator then there is a bigger problem. You may as well just generate a map using the numbers from FoxPro and get the numbers from there.
The only way you will achieve this is create a Visual FoxPro COM object with a method that takes a seed value and returns the random number generated, then use that via COM Interop in C#.
There is NO WAY TO MAKE NATIVE C# DO THIS. So stop asking.
I'm not sure why you would want to do that but here is a Visual FoxPro Toolkit for .NET http://foxcentral.net/microsoft/vfptoolkitnet.htm its possible it might have the same rand generator function.
You can't. You are setting a seed value, but the chance that .NET and FoxPro is using exactly the same method to generate Random numbers is close to zero. But question is, why would you want this? Random is supposed to be random.
What you ask IS possible. You just can't use the generators provided to you by Foxpro and the .NET framework.
Most "random" number generators just generate sequence of numbers that "look" or "feel" random. They work like this (very simplified): Start with a "seed" value, apply a transform and generate a value, then apply the transform to this value and get next. Repeat as needed. The transform is such that you can expect the values to be uniformly distributed within a given segment, usually [0,1). I can explain this further, but there is plenty of literature around. Search for it.
Now, obviously, if you provide any given generator with the same seed, you will get the same sequence over and over again.
So, to obtain the result you want, you need to implement your own pseudo-random number generator in both VFP and C#. Keep in mind that there are things like difference in precision that could make successive calls to the generator, diverge.
Anyway, you will need an algorithm. Go here: use of D.Knuth pseudo-random generator
Hope this is still useful.