Understanding the algorithm of Visual C++'s rand() function

后端 未结 5 1571
渐次进展
渐次进展 2021-01-02 04:52

In C/C++, rand() and srand() are usually used by us when we want to get a random integer. But when I tried to rewrite it myself, I found it difficu

5条回答
  •  臣服心动
    2021-01-02 05:05

    You can find an explanation of the Linear Congruential Generator (LCG) and other similar families or pseudo random generators, and about the selection of these specific constants in an excellent article published this month (7-2011) in Dr. Dobb's Journal (DDJ): Fast, High-Quality, Parallel Random-Number Generators: Comparing Implementations.

    I think you'll need to register at DDJ's website (free) to read the first part of this article (link), but if you're into C++ and mathematics you should do it anyway...

提交回复
热议问题