Example #1
0
 public static object TrueDivide(object a, object b)
 {
     if (a is int)
     {
         return(IntOps.TrueDivide((int)a, b));
     }
     else if (a is long)
     {
         return(Int64Ops.TrueDivide((long)a, b));
     }
     else if (a is IronMath.BigInteger)
     {
         return(LongOps.TrueDivide((IronMath.BigInteger)a, b));
     }
     return(Ops.Divide(a, b));
 }
Example #2
0
        public static object Abs(object o)
        {
            if (o is int)
            {
                return(IntOps.Abs((int)o));
            }
            if (o is long)
            {
                return(Int64Ops.Abs((long)o));
            }
            if (o is double)
            {
                return(FloatOps.Abs((double)o));
            }
            if (o is bool)
            {
                return(((bool)o) ? 1 : 0);
            }
            if (o is string)
            {
                throw Ops.TypeError("bad operand type for abs()");
            }
            BigInteger bi = o as BigInteger;

            if (!Object.Equals(bi, null))
            {
                return(LongOps.Abs(bi));
            }
            if (o is Complex64)
            {
                return(ComplexOps.Abs((Complex64)o));
            }

            object ret;

            if (Ops.TryToInvoke(o, SymbolTable.AbsoluteValue, out ret))
            {
                return(ret);
            }
            else
            {
                throw Ops.TypeError("bad operand type for abs()");
            }
        }