implementation of rand()

后端 未结 11 1423
遥遥无期
遥遥无期 2020-12-01 01:34

I am writing some embedded code in C and need to use the rand() function. Unfortunately, rand() is not supported in the library for the controller. I need a simple implement

11条回答
  •  [愿得一人]
    2020-12-01 02:30

    Check out this collection of random number generators from George Marsaglia. He's a leading expert in random number generation, so I'd be confident using anything he recommends. The generators in that list are tiny, some requiring only a couple unsigned longs as state.

    Marsaglia's generators are definitely "high quality" by your standards of long period and good uniform distribution. They pass stringent statistical tests, though they wouldn't do for cryptography.

提交回复
热议问题