什么是微软不保证Random类的实现跨版本的.NET中保持不变的原因是什么? [英] What is the reason Microsoft don't guarantee the implementation of Random class to remain the same across version of .NET?

查看:138
本文介绍了什么是微软不保证Random类的实现跨版本的.NET中保持不变的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线文档

注释调用者:随机数生成器的实现   Random类不能保证留在主要同   .NET Framework的版本。这样一来,你的应用程序code   不应假设相同的种子,将导致在同一个   不同版本的.NET Framework的伪随机序列。

Notes to Callers: The implementation of the random number generator in the Random class is not guaranteed to remain the same across major versions of the .NET Framework. As a result, your application code should not assume that the same seed will result in the same pseudo-random sequence in different versions of the .NET Framework.

什么是Microsoft不能保证Random类的实现跨版本的.NET中保持不变的原因是什么?更具体地说,是什么原因微软不保证相同的种子产生随机数的相同的序列跨越.NET框架的主要版本?

What is the reason Microsoft don't guarantee the implementation of Random class to remain the same across version of .NET? More specifically, what is the reason Microsoft don't guarantee the same seed to produce the same sequence of random numbers across major version of .NET framework?

推荐答案

有与高度upvoted后一个问题。 Random类肯定会产生predictable号码。从为随机(Int32)在构造函数的文档:

There's a problem with the highly upvoted post. The Random class most certainly generates predictable numbers. From the documentation for the Random(Int32) constructor:

提供了一个相同的种子值不同的随机对象,使每个实例产生的随机数相同的序列。

Providing an identical seed value to different Random objects causes each instance to produce identical sequences of random numbers.

微软做的没有的要保证的是,这种序列会在其他.NET框架版本相同。有一个很好的理由,他们不能肯定,如果他们所使用的算法是的完全的无缺陷。使用Random类弱势群体或承担责任的种类,使code产生偏见的结果。赔率非常低,但不是零。

What Microsoft does not want to promise is that this sequence will be identical in another .NET Framework release. There's a good reason for that, they cannot be sure if the algorithm they used is completely free of flaws. The kind that makes code that uses the Random class vulnerable or liable to generate biased results. Odds are very low but not zero.

有precedent为此,最臭名昭著情况是与随机生成器,IBM公司在他们的大型机软件中使用的问题,所谓的 RANDU 。引述被广泛认为是最不济的随机数发生器设计过的一个。它有pretty的明显瑕疵,一旦分析师开始采取更好的了解一下吧。首先标记于1963年,它仍然广泛应用于20世纪70年代。

There is precedent for this, the most infamous case was a problem with the random generator that IBM used in their mainframe software, called RANDU. Quoted as "Widely considered to be one of the most ill-conceived random number generators ever designed". It has pretty obvious flaws once analysts started to take a better look at it. First flagged in 1963, it was still widely used in the 1970s.

这篇关于什么是微软不保证Random类的实现跨版本的.NET中保持不变的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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