[Mono-bugs] [Bug 76488][Nor] Changed - System.Random().Next() and System.Random().NextDouble() generate the same consecutive random numbers

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Oct 20 08:39:03 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76488

--- shadow/76488	2005-10-20 06:32:28.000000000 -0400
+++ shadow/76488.tmp.14161	2005-10-20 08:39:03.000000000 -0400
@@ -1,16 +1,16 @@
 Bug#: 76488
 Product: Mono: Class Libraries
 Version: 1.1
 OS: unknown
 OS Details: gentoo 2.6.12.5
-Status: NEW   
-Resolution: 
+Status: RESOLVED   
+Resolution: NOTABUG
 Severity: Unknown
-Priority: Major
-Component: System
+Priority: Normal
+Component: CORLIB
 AssignedTo: mono-bugs at ximian.com                            
 ReportedBy: aeyakovenko at gmail.com               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
@@ -56,6 +56,24 @@
 a new instance of the Random object for each number. This won't work
 well as Random is initialized with the current time (in seconds
 granularity) as seed. So you'll get the same number for 1 second.
 
 The correct usage would be to create 1 random object and then reuse it
 for all numbers.
+
+------- Additional Comments From sebastien at ximian.com  2005-10-20 08:39 -------
+System.Random is deterministic, i.e. with the same seed value it will
+generate the same (pseudo-)random data stream. This is a feature - not
+a bug.
+
+The default Random ctor gets seeded with Environment.TickCount (in
+milliseconds resolution). So creating multiple Random instance in fast
+succession can lead to identical seed (over multiple instances), which
+will return the same data.
+
+Random doesn't provide "quality" random data (it's main quality is
+being fast). You should use the
+System.Security.Cryptography.RNGCryptoServiceProvider class if you
+want non-reproducible, high-quality (not perfect) random data.
+
+note: Please re-open the bug if I didn't understand your code
+correctly (and provide a C# version).


More information about the mono-bugs mailing list