implementation of rand()

后端 未结 11 1446
遥遥无期
遥遥无期 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:09

    I found this: Simple Random Number Generation, by John D. Cook.

    It should be easy to adapt to C, given that it's only a few lines of code.

    Edit: and you could clarify what you mean by "relatively high-quality". Are you generating encryption keys for nuclear launch codes, or random numbers for a game of poker?

提交回复
热议问题