Why does C++ rand() seem to generate only numbers of the same order of magnitude?

前端 未结 9 2188
孤独总比滥情好
孤独总比滥情好 2021-01-30 01:14

In a small application written in C/C++, I am facing a problem with the rand function and maybe the seed :

I want to produce a sequence of random numbers th

9条回答
  •  我在风中等你
    2021-01-30 01:44

    There are only 3% of numbers between 1 and 230 which are NOT between 225 and 230. So, this sounds pretty normal :)

    Because 225 / 230 = 2-5 = 1/32 = 0.03125 = 3.125%

提交回复
热议问题