public LargeInt(LargeInt copyFrom) { _thisVal = copyFrom._thisVal; if (copyFrom._overflow != null) { _overflow = copyFrom._overflow; } }
public void Add(LargeInt value) { if (value._overflow == null) { this.Add(value._thisVal); } else { this._overflow.Add(value); } }
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); } }
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]); }
public LargeInt Fib3(int i, out LargeInt[] series) { series = new LargeInt[i + 1]; return(_Fib3(i, ref series)); }