Beispiel #1
0
 public abstract LispNumber Add(LispBigInteger addend);
Beispiel #2
0
 protected static bool NumberEquals(LispBigInteger a, LispBigInteger b)
 {
     return a.Value == b.Value;
 }
Beispiel #3
0
 protected static bool NumberEquals(LispBigInteger a, LispDouble b)
 {
     return IsIntegral(b.Value) && a.Value == (BigInteger)b.Value;
 }
Beispiel #4
0
 public override int CompareTo(LispBigInteger number)
 {
     return -Compare(number, this);
 }
Beispiel #5
0
 protected static LispNumber Multiply(LispBigInteger a, LispBigInteger b)
 {
     return MakeNumber(a.Value * b.Value);
 }
Beispiel #6
0
 public abstract LispNumber DivideInto(LispBigInteger dividend);
Beispiel #7
0
 public abstract bool NumberEquals(LispBigInteger number);
Beispiel #8
0
 public override int CompareTo(LispBigInteger number)
 {
     return Value.CompareTo(number.Value);
 }
Beispiel #9
0
 public override LispNumber DivideBy(LispBigInteger divisor)
 {
     return Divide(this, divisor);
 }
Beispiel #10
0
 public override bool NumberEquals(LispBigInteger number)
 {
     return NumberEquals(this, number);
 }
Beispiel #11
0
 public override LispNumber Add(LispBigInteger addend)
 {
     return Add(this, addend);
 }
Beispiel #12
0
 public override LispNumber Multiply(LispBigInteger factor)
 {
     return Multiply(this, factor);
 }
Beispiel #13
0
 public override LispNumber DivideInto(LispBigInteger dividend)
 {
     return Divide(dividend, this);
 }
Beispiel #14
0
 public override int CompareTo(LispBigInteger number)
 {
     return Compare(this, number);
 }
Beispiel #15
0
 public abstract int CompareTo(LispBigInteger number);
Beispiel #16
0
 protected static int Compare(LispInteger a, LispBigInteger b)
 {
     return ((BigInteger)a.Value).CompareTo(b.Value);
 }
Beispiel #17
0
 public abstract LispNumber DivideBy(LispBigInteger divisor);
Beispiel #18
0
        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;
        }
Beispiel #19
0
 public abstract LispNumber Multiply(LispBigInteger factor);
Beispiel #20
0
        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);
        }
Beispiel #21
0
 protected static LispNumber Add(LispBigInteger a, LispBigInteger b)
 {
     return MakeNumber(a.Value + b.Value);
 }
Beispiel #22
0
 public LispDouble(LispBigInteger bigInteger)
 {
     this.Value = (double)bigInteger.Value;
 }