public static object Multiply(double x, object other) { if (other is double) { return(x * ((double)other)); } if (other is int) { return(x * ((int)other)); } if (other is Complex64) { return(ComplexOps.Multiply(Complex64.MakeReal(x), (Complex64)other)); } if (other is BigInteger) { return(x * ((BigInteger)other)); } if (other is float) { return(x * ((float)other)); } if (other is ExtensibleFloat) { return(x * ((ExtensibleFloat)other).value); } if (other is string) { return(Ops.NotImplemented); } if (other is IConvertible) { double y = ((IConvertible)other).ToDouble(null); return(x * y); } if (other is long) { return(x * ((long)other)); } if (other is ExtensibleInt) { return(x * ((ExtensibleInt)other).value); } if (other is ExtensibleComplex) { return(ComplexOps.Multiply(Complex64.MakeReal(x), ((ExtensibleComplex)other).value)); } return(Ops.NotImplemented); }
public static object Mod(Complex64 x, object other) { object rawQuotient = ComplexOps.FloorDivide(x, other); if (rawQuotient == Ops.NotImplemented) { return(rawQuotient); } if (rawQuotient is Complex64) { Complex64 complexQuotient = (Complex64)rawQuotient; Complex64 product = (Complex64)ComplexOps.Multiply(complexQuotient, other); return(ComplexOps.Subtract(x, product)); } else { return(Ops.NotImplemented); } }
public static object Multiply(int x, object other) { if (other is int) { int y = (int)other; try { return(Ops.Int2Object(checked (x * y))); } catch (OverflowException) { return(BigInteger.Create(x) * y); } } else if (other is BigInteger) { return(BigInteger.Create(x) * (BigInteger)other); } else if (other is double) { return(x * (double)other); } else if (other is Complex64) { return(ComplexOps.Multiply(Complex64.MakeReal(x), other)); } else if (other is bool) { bool b = (bool)other; return(x * (b ? 1 : 0)); } else if (other is long) { long y = (long)other; try { return(checked (x * y)); } catch (OverflowException) { return(BigInteger.Create(x) * y); } } else if (other is float) { return(x * (float)other); } else if (other is byte) { return(x * (byte)other); } else if (other is ExtensibleInt) { int y = ((ExtensibleInt)other).value; try { return(Ops.Int2Object(checked (x * y))); } catch (OverflowException) { return(BigInteger.Create(x) * y); } } else if (other is ExtensibleFloat) { return(x * ((ExtensibleFloat)other).value); } else if (other is ExtensibleComplex) { return(ComplexOps.Multiply(Complex64.MakeReal(x), (ExtensibleComplex)other)); } else if (other is byte) { int y = (byte)other; try { return(Ops.Int2Object(checked (x * y))); } catch (OverflowException) { return(BigInteger.Create(x) * y); } } return(Ops.NotImplemented); }