Example #1
0
        /// <summary>
        /// equality test between two digit lists.
        /// </summary>
        public override bool Equals(Object obj)
        {
            if (this == obj)             // quick check
            {
                return(true);
            }
            if (!(obj is DigitList))             // (1) same object?
            {
                return(false);
            }
            DigitList other = (DigitList)obj;

            if (Count != other.Count || DecimalAt != other.DecimalAt)
            {
                return(false);
            }
            for (int i = 0; i < Count; i++)
            {
                if (Digits[i] != other.Digits[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
 /// <summary>
 /// Creates a copy of this object. </summary>
 /// <returns> a clone of this instance. </returns>
 public Object Clone()
 {
     try
     {
         DigitList other     = (DigitList)base.Clone();
         char[]    newDigits = new char[Digits.Length];
         System.Array.Copy(Digits, 0, newDigits, 0, Digits.Length);
         other.Digits     = newDigits;
         other.TempBuffer = null;
         return(other);
     }
     catch (CloneNotSupportedException e)
     {
         throw new InternalError(e);
     }
 }