How to return the same random number in different systems?

Asked

Viewed 92 times

0

A pseudo-random number generator like the rand() of PHP and the new Random.Next() of . NET will return different values same using the same seed and even full range, and this is not the right way for my project to work correctly on different platforms.

For example, I have compiled a random seed number 123 within a range of 1 à 100, and in all compilers of . NET returned 98 on the first call. But using the same script in PHP, it was returned 7, which makes no connection to the compiler of .NET.

Below is the code used in .NET to generate the random number by rextester.com site

inserir a descrição da imagem aqui

Here, another example, same code, same output, only compiled in Dotnetfiddle

inserir a descrição da imagem aqui

And anyway, the same code practically, but compiled in PHP:

inserir a descrição da imagem aqui

And also in C++ this occurs:

inserir a descrição da imagem aqui

How can I make a random number to be generated exactly the same seed only on another platform?

  • 4

    Creating your own algorithm. What you want is not a random number, it is a previously determined number.

  • @bigown Could you show me examples, formulas or circuits that cause a near random number?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.