public object RichEquals(object other) { ExtensibleFloat ei = other as ExtensibleFloat; if (ei != null) { return(Ops.Bool2Object(value == ei.value)); } if (other is double) { return(Ops.Bool2Object(value == (double)other)); } if (other is float) { return(Ops.Bool2Object(value == (float)other)); } return(Ops.NotImplemented); }
public static object Mod(double x, object other) { if (other is int) { int y = (int)other; if (y == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } if (other is long) { long y = (long)other; if (y == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } if (other is Complex64) { Complex64 y = (Complex64)other; if (y.IsZero) { throw Ops.ZeroDivisionError(); } return(ComplexOps.Mod(Complex64.MakeReal(x), y)); } if (other is double) { double y = (double)other; if (y == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } if (other is BigInteger) { BigInteger y = (BigInteger)other; if (y == BigInteger.Zero) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } if (other is ExtensibleFloat) { ExtensibleFloat y = (ExtensibleFloat)other; if (y.value == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y.value)); } if (other is ExtensibleInt) { int y = ((ExtensibleInt)other).value; if (y == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } if (other is ExtensibleComplex) { Complex64 y = ((ExtensibleComplex)other).value; if (y.IsZero) { throw Ops.ZeroDivisionError(); } return(ComplexOps.Mod(Complex64.MakeReal(x), y)); } if (other is IConvertible) { double y = ((IConvertible)other).ToDouble(null); if (y == 0) { throw Ops.ZeroDivisionError(); } return(Modulo(x, y)); } return(Ops.NotImplemented); }