Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow 'double' arguments with '=='

  • Loading branch information...
commit 6fb3612c44d4c4e8f547de4655113b2a86031344 1 parent 379dcbb
@dharmatech authored
Showing with 13 additions and 16 deletions.
  1. +5 −8 Symbolism/Program.cs
  2. +8 −8 Tests/Program.cs
View
13 Symbolism/Program.cs
@@ -80,21 +80,18 @@ public abstract class MathObject
#endregion
//////////////////////////////////////////////////////////////////////
- //public static Equation operator ==(MathObject a, double b)
- //{ return new Equation(a, new DoubleFloat(b)); }
-
public static Equation operator ==(MathObject a, MathObject b)
{ return new Equation(a, b); }
- //public static Equation operator !=(MathObject a, MathObject b)
- //{ return new Equation(a, b); }
-
- //public static NotEqual operator !=(MathObject a, MathObject b)
- //{ return new NotEqual(a, b); }
+ public static Equation operator ==(MathObject a, double b)
+ { return new Equation(a, new DoubleFloat(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 MathObject operator +(MathObject a, MathObject b)
{ return new Sum(a, b).Simplify(); }
View
16 Tests/Program.cs
@@ -93,8 +93,8 @@ static void Main(string[] args)
AssertIsTrue(Int(10).Substitute(Int(10), Int(20)) == Int(20));
AssertIsTrue(Int(10).Substitute(Int(15), Int(20)) == Int(10));
- AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.0), new DoubleFloat(2.0)) == new DoubleFloat(2.0));
- AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.5), new DoubleFloat(2.0)) == new DoubleFloat(1.0));
+ AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.0), new DoubleFloat(2.0)) == 2.0);
+ AssertIsTrue(new DoubleFloat(1.0).Substitute(new DoubleFloat(1.5), new DoubleFloat(2.0)) == 1.0);
AssertIsTrue((Int(1) / 2).Substitute(Int(1) / 2, Int(3) / 4) == Int(3) / 4);
AssertIsTrue((Int(1) / 2).Substitute(Int(1) / 3, Int(3) / 4) == Int(1) / 2);
@@ -123,7 +123,7 @@ static void Main(string[] args)
Func<MathObject, MathObject> sin = arg => new Sin(arg).Simplify();
- AssertIsTrue(sin(new DoubleFloat(3.14159 / 2)) == new DoubleFloat(0.99999999999911982));
+ AssertIsTrue(sin(new DoubleFloat(3.14159 / 2)) == 0.99999999999911982);
AssertIsTrue(sin(x + y) + sin(x + y) == 2 * sin(x + y));
@@ -131,7 +131,7 @@ static void Main(string[] args)
AssertIsTrue(sin(x + x).Substitute(x, Int(1)) == sin(Int(2)));
- AssertIsTrue(sin(x + x).Substitute(x, new DoubleFloat(1.0)) == new DoubleFloat(0.90929742682568171));
+ AssertIsTrue(sin(x + x).Substitute(x, new DoubleFloat(1.0)) == 0.90929742682568171);
AssertIsTrue(sin(2 * x).Substitute(x, y) == sin(2 * y));
@@ -195,8 +195,8 @@ static void Main(string[] args)
.Substitute(g, new DoubleFloat(9.8))
.Substitute(Trig.Pi, new DoubleFloat(3.14159))
.Substitute(vA, new Integer(11))
- ==
- new DoubleFloat(7.9364536850196412));
+ ==
+ 7.9364536850196412);
//Console.WriteLine("Maximum height reached: ");
@@ -206,8 +206,8 @@ static void Main(string[] args)
.Substitute(thA, Trig.ToRadians(20))
.Substitute(Trig.Pi, new DoubleFloat(3.14159))
.Substitute(vA, new Integer(11))
- ==
- new DoubleFloat(0.72215756424454336));
+ ==
+ 0.72215756424454336);
}
Console.WriteLine("Testing complete");
Please sign in to comment.
Something went wrong with that request. Please try again.