开发者

Randoms numbers on iPhone

开发者 https://www.devze.com 2022-12-09 04:09 出处:网络
What is better? I have the prioritized in the order of \"goodness\", am I correct? 开发者_如何学Go

What is better? I have the prioritized in the order of "goodness", am I correct?

开发者_如何学Go
  1. arc4random
  2. randmom
  3. rand

1 - best, 3 - worst

I need a really good randmon number gen for a lowe number (< 50), so I using % 50 to obtain numbers below 50.

Thanks


I'm pretty sure randMOM is the one to use.

Oh, well, first google hit.

If you need a number in the range [n, m), the very best approach is to use a function explicitly designed to do so. Both scaling (from say [0, 1)) and applying a modulus may slightly alter the distribution. Of course, such skewing may be entirely irrelevant (and for most applications is probably only a theoretical consideration) -- especially if only a basic PRNG is employed.

0

精彩评论

暂无评论...
验证码 换一张
取 消