Better seeds than time(0)?

前端 未结 11 1833
挽巷
挽巷 2021-01-02 08:06

I understand that time(0) is commonly using for seeding random number generators and that it only becomes a problem when the program is being run more than once per second.

11条回答
  •  被撕碎了的回忆
    2021-01-02 08:44

    Using tickCout() or anything with a high frequency is a bad idea. This is becuase the couter cycles back to zero very quickly thus gives the posability of having the same seed.

    time(NULL):   Repeats every 64 years.  
    tickCouter()  Repeats every X days.
    

    You could try and get some random value from nature.
    Lightining strikes world wide in the last second (appatently that is online)? (You may need to do research to see if that is variable though).

提交回复
热议问题