在iphone sdk播种arc4random() [英] seeding arc4random() in iphone sdk

查看:130
本文介绍了在iphone sdk播种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 -bit伪随机
数字非常快。 arc4random()定期从
中定义内核强随机数子系统 random(4)

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.

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

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