public static object ReverseFloorDivide(BigInteger x, object other) { if (other is int) { return(IntOps.Divide((int)other, x)); } if (other is Complex64) { Complex64 y = (Complex64)other; if (y.IsZero) { throw Ops.ZeroDivisionError(); } return(ComplexOps.Divide(y, Complex64.MakeReal(x))); } if (other is double) { return(FloatOps.FloorDivide((double)other, x)); } if (other is bool) { return(Divide((bool)other ? 1 : 0, x)); } if (other is long) { return(Divide((long)other, x)); } if (other is BigInteger) { return(Divide((BigInteger)other, x)); } if (other is ExtensibleInt) { return(Divide(((ExtensibleInt)other).value, x)); } if (other is ExtensibleComplex) { Complex64 y = ((ExtensibleComplex)other).value; if (y.IsZero) { throw Ops.ZeroDivisionError(); } return(ComplexOps.FloorDivide(y, Complex64.MakeReal(x))); } if (other is byte) { return(IntOps.Divide((int)((byte)other), x)); } if (other is ExtensibleFloat) { return(FloatOps.FloorDivide(((ExtensibleFloat)other).value, x)); } return(Ops.NotImplemented); }
public static object Divide(bool x, object other) { if (other is bool) { return(IntOps.Divide(x ? 1 : 0, (bool)other ? 1 : 0)); } else { return(IntOps.Divide(x ? 1 : 0, other)); } }