Mono.Math.BigInteger.Normalize C# (CSharp) Méthode

Normalize() private méthode

Normalizes this by setting the length to the actual number of uints used in data and by setting the sign to Sign.Zero if the value of this is 0.
private Normalize ( ) : void
Résultat void
		private void Normalize ()
		{
			// Normalize length
			while (length > 0 && data [length-1] == 0) length--;

			// Check for zero
			if (length == 0)
				length++;
		}

Usage Example

Exemple #1
0
            public static BigInteger RightShift(BigInteger bi, int n)
            {
                if (n == 0)
                {
                    return(new BigInteger(bi));
                }

                int w = n >> 5;
                int s = n & ((1 << 5) - 1);

                BigInteger ret = new BigInteger(Sign.Positive, bi.length - (uint)w + 1);
                uint       l   = (uint)ret.data.Length - 1;

                if (s != 0)
                {
                    uint x, carry = 0;

                    while (l-- > 0)
                    {
                        x           = bi.data[l + w];
                        ret.data[l] = (x >> n) | carry;
                        carry       = x << (32 - n);
                    }
                }
                else
                {
                    while (l-- > 0)
                    {
                        ret.data[l] = bi.data[l + w];
                    }
                }
                ret.Normalize();
                return(ret);
            }
All Usage Examples Of Mono.Math.BigInteger::Normalize