Permalink
Browse files

Add overload for ==(double a, MathObject b)

  • Loading branch information...
1 parent 6fb3612 commit 6bf4724cd96c99bc3b148b25cdc676a15b40ebc1 @dharmatech committed Jan 20, 2013
Showing with 10 additions and 0 deletions.
  1. +6 −0 Symbolism/Program.cs
  2. +4 −0 Tests/Program.cs
View
@@ -86,12 +86,18 @@ public abstract class MathObject
public static Equation operator ==(MathObject a, double b)
{ return new Equation(a, new DoubleFloat(b)); }
+ public static Equation operator ==(double a, MathObject b)
+ { return new Equation(new DoubleFloat(a), b); }
+
public static Equation operator !=(MathObject a, MathObject b)
{ return new Equation(a, b, Equation.Operators.NotEqual); }
public static Equation operator !=(MathObject a, double b)
{ return new Equation(a, new DoubleFloat(b), Equation.Operators.NotEqual); }
+ public static Equation operator !=(double a, MathObject b)
+ { return new Equation(new DoubleFloat(a), b, Equation.Operators.NotEqual); }
+
//////////////////////////////////////////////////////////////////////
public static MathObject operator +(MathObject a, MathObject b)
{ return new Sum(a, b).Simplify(); }
View
@@ -144,6 +144,10 @@ static void Main(string[] args)
AssertIsTrue(x != y);
AssertIsTrue(x != new Integer(10));
+
+ // ==(double a, MathObject b)
+
+ AssertIsTrue(1.0 == new DoubleFloat(3.0) - 2.0);
}
{

0 comments on commit 6bf4724

Please sign in to comment.