Random numbers across different programming languages

后端 未结 3 393
刺人心
刺人心 2020-12-21 13:53

If I use the Random number generator function in different programming languages and I chose the same seed .. Do they have to give me the same random numbers ?

for e

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 14:27

    Just want to add, there is no such thing as 'random' in computer science.

    Random number generation depends on the mathematical function used to generate the number. For example, Java uses 'Linear Congruential generator'.

    If two programming languages use exact same function, theoretically they should give same 'random' number.

    If you are interested more on how random numbers are generated, There is a good publication, The Art of Computer Programming by Donald Knuth.

提交回复
热议问题