public abstract LispNumber Add(LispBigInteger addend);
protected static bool NumberEquals(LispBigInteger a, LispBigInteger b) { return a.Value == b.Value; }
protected static bool NumberEquals(LispBigInteger a, LispDouble b) { return IsIntegral(b.Value) && a.Value == (BigInteger)b.Value; }
public override int CompareTo(LispBigInteger number) { return -Compare(number, this); }
protected static LispNumber Multiply(LispBigInteger a, LispBigInteger b) { return MakeNumber(a.Value * b.Value); }
public abstract LispNumber DivideInto(LispBigInteger dividend);
public abstract bool NumberEquals(LispBigInteger number);
public override int CompareTo(LispBigInteger number) { return Value.CompareTo(number.Value); }
public override LispNumber DivideBy(LispBigInteger divisor) { return Divide(this, divisor); }
public override bool NumberEquals(LispBigInteger number) { return NumberEquals(this, number); }
public override LispNumber Add(LispBigInteger addend) { return Add(this, addend); }
public override LispNumber Multiply(LispBigInteger factor) { return Multiply(this, factor); }
public override LispNumber DivideInto(LispBigInteger dividend) { return Divide(dividend, this); }
public override int CompareTo(LispBigInteger number) { return Compare(this, number); }
public abstract int CompareTo(LispBigInteger number);
protected static int Compare(LispInteger a, LispBigInteger b) { return ((BigInteger)a.Value).CompareTo(b.Value); }
public abstract LispNumber DivideBy(LispBigInteger divisor);
protected static int Compare(LispBigInteger a, LispDouble b) { var truncatedB = new BigInteger(b.Value); var truncatedCompare = a.Value.CompareTo(truncatedB); if (truncatedCompare == 0) { return -Math.Truncate(b.Value).CompareTo(b.Value); } return truncatedCompare; }
public abstract LispNumber Multiply(LispBigInteger factor);
protected static LispNumber Divide(LispBigInteger dividend, LispBigInteger divisor) { BigInteger remainder; BigInteger quotient = BigInteger.DivRem(dividend.Value, divisor.Value, out remainder); if (remainder != 0) { return Divide((LispDouble)dividend, (LispDouble)divisor); } return MakeNumber(quotient); }
protected static LispNumber Add(LispBigInteger a, LispBigInteger b) { return MakeNumber(a.Value + b.Value); }
public LispDouble(LispBigInteger bigInteger) { this.Value = (double)bigInteger.Value; }