开发者

Randoms numbers on iPhone

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜