2004-12-03 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / Mono.Math / BigInteger.cs
index 4535e1a6ef20a2995f6da443894a96c71a6358ae..20c6d0eb11fe43a553b39cd82d3ba897da3d6b45 100644 (file)
@@ -12,7 +12,6 @@
 //
 // Copyright (c) 2002 Chew Keong TAN
 // All rights reserved.
-
 //
 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
 //
@@ -171,6 +170,7 @@ namespace Mono.Math {
                public BigInteger ()
                {
                        data = new uint [DEFAULT_LEN];
+                       this.length = DEFAULT_LEN;
                }
 
 #if !INSIDE_CORLIB
@@ -559,6 +559,9 @@ namespace Mono.Math {
                /// <param name="rng">A RNG.</param>
                public void Randomize (RandomNumberGenerator rng)
                {
+                       if (this == 0)
+                               return;
+
                        int bits = this.BitCount ();
                        int dwords = bits >> 5;
                        int remBits = bits & 0x1F;
@@ -1017,7 +1020,7 @@ namespace Mono.Math {
 
                                r2.Normalize ();
 
-                               if (r2 < x) {
+                               if (r2 <= x) {
                                        Kernel.MinusEq (x, r2);
                                } else {
                                        BigInteger val = new BigInteger (Sign.Positive, kPlusOne + 1);