在iOS中播种arc4random() [英] seeding arc4random() in iOS

查看:79
本文介绍了在iOS中播种arc4random()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的收集, arc4random()生成的随机数要比 rand()好得多,但是我还没有找到播种它的方法,因此我想就像使用 srand()一样。有办法吗?

From what I can gather arc4random() generates much better random numbers than rand() does, however I haven't seen a way to seed it, and I would like to just like using srand(). Is there a way?

推荐答案

这不是arc4random设计的目的。如文档所述:

That's not what arc4random is designed to do. As the documentation states:


arc4random()函数可提供高质量的32位伪随机
数字很快。 arc4random()定期从
中自己植入

The arc4random() function provides a high quality 32-bit pseudo-random number very quickly. arc4random() seeds itself on a regular basis from the kernel strong random number subsystem described in random(4).

由于它是从熵源重新播种的,因此您通过手动播种不会获得任何收益,实际上,这种方法不存在。

Since it is re-seeds itself from an entropy source anyway, you gain nothing by seeding it manually, and in fact, such a method does not exist.

这篇关于在iOS中播种arc4random()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆