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

前端 未结 4 1915
孤独总比滥情好
孤独总比滥情好 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:36

    rnum = (rand() << 15) | rand() might be faster, but if you need good quality random numbers you should look for an external library. Built-in random functions are generally adequate only for the simplest applications.

提交回复
热议问题