Exemple #1
0
 public LargeInt(LargeInt copyFrom)
 {
     _thisVal = copyFrom._thisVal;
     if (copyFrom._overflow != null)
     {
         _overflow = copyFrom._overflow;
     }
 }
Exemple #2
0
 public void Add(LargeInt value)
 {
     if (value._overflow == null)
     {
         this.Add(value._thisVal);
     }
     else
     {
         this._overflow.Add(value);
     }
 }
Exemple #3
0
 public void Add(long value)
 {
     if (_overflow == null)
     {
         var _remainingSpace = long.MaxValue - _thisVal;
         if (_remainingSpace < value)
         {
             // overflow will happen
             _thisVal  = long.MaxValue;
             _overflow = new LargeInt(value - _remainingSpace);
         }
         else
         {
             // no overflow
             _thisVal += value;
         }
     }
     else
     {
         _overflow.Add(value);
     }
 }
Exemple #4
0
        LargeInt _Fib3(int i, ref LargeInt[] series)
        {
            if (i == 0)
            {
                return(new LargeInt(0));
            }
            if (i == 1)
            {
                return(new LargeInt(1));
            }

            if (i > 1)
            {
                series[0] = new LargeInt(0);
                series[1] = new LargeInt(1);

                for (var j = 2; j <= i; j++)
                {
                    series[j] = new LargeInt(series[j - 1]);
                    series[j].Add(series[j - 2]);
                }
            }
            return(series[i]);
        }
Exemple #5
0
 public LargeInt Fib3(int i, out LargeInt[] series)
 {
     series = new LargeInt[i + 1];
     return(_Fib3(i, ref series));
 }