How to get a larger random number from the c function rand()

前端 未结 4 1919
孤独总比滥情好
孤独总比滥情好 2021-01-19 21:19

I am in a coding environment where I only have access to some most basic c functions. #include\'ing other lib is not feasible.

In this environment, I can call rand()

4条回答
  •  佛祖请我去吃肉
    2021-01-19 21:46

    Before using ANY random number generator for a non-trivial use, it should be tested extensively. Here is a link to one article on this subject.

    A fun background on the weaknesses of even true random numbers is available in the various histories on the code-breakers at Bletchley Park in WWII. The Germans and Hitler for most of the war assumed their codes were unbreakable because of being encrypted with random numbers, whereas the British were breaking all of these codes completely within months because of various weaknesses in the German implementation of "randomness". Many codes were sufficiently "twisted", if not outright broken, within a few days or months, sufficiently to be of use even though not completely broken.

提交回复
热议问题