static void AssertDiv0Mod0(int x1, int x2) { var nd = SchemeImpl.Div0(x1, x2); var xm = SchemeImpl.Mod0(x1, x2); AssertDiv0Mod0(x1, x2, nd, xm); }
static void AssertDiv0Mod0(int x1, int x2) { var nd = SchemeImpl.Div0(x1, x2); var xm = SchemeImpl.Mod0(x1, x2); var r = SchemeImpl.Div0Mod0(x1, x2); Assert.AreEqual(nd, r.Item1); Assert.AreEqual(xm, r.Item2); AssertDiv0Mod0(x1, x2, nd, xm); }
static void Main(string[] args) { var sw = new Stopwatch(); var r = SchemeImpl.Div(123, 10); for (int i = 0; i < 500000; i++) { r = SchemeImpl.Div(123, 10); //r = SchemeImpl.DivSlow(123, 10); r = SchemeImpl.Div0(123, 10); //r = SchemeImpl.Div0Slow(123, 10); } const int MAX = 500000000; sw.Start(); for (int i = 1; i < MAX; i++) { r = SchemeImpl.Div(i, MAX - i); r = SchemeImpl.Div(i, 0 - i); r = SchemeImpl.Div(MAX - i, i); r = SchemeImpl.Div(0 - i, i); } sw.Stop(); Console.WriteLine("Div: {0:f3}s", sw.Elapsed.TotalSeconds); /* * sw.Restart(); * * for (int i = 1; i < MAX; i++) * { * r = SchemeImpl.DivSlow(i, 0 - i); * } * * sw.Stop(); * * Console.WriteLine("DivSlow: {0:f3}s", sw.Elapsed.TotalSeconds); */ sw.Restart(); for (int i = 1; i < MAX; i++) { r = SchemeImpl.Div0(i, MAX - i); r = SchemeImpl.Div0(i, 0 - i); r = SchemeImpl.Div0(MAX - i, i); r = SchemeImpl.Div0(0 - i, i); } sw.Stop(); Console.WriteLine("Div0: {0:f3}s", sw.Elapsed.TotalSeconds); /* * sw.Restart(); * * for (int i = 1; i < MAX; i++) * { * r = SchemeImpl.Div0Slow(i, 0 - i); * } * * sw.Stop(); * * Console.WriteLine("Div0Slow: {0:f3}s", sw.Elapsed.TotalSeconds); */ Console.WriteLine(r); }
public void TestDiv0NN() { Assert.AreEqual(12, SchemeImpl.Div0(-123, -10)); }
public void TestDiv0PP() { Assert.AreEqual(12, SchemeImpl.Div0(123, 10)); }
public void TestDiv0NN() { Assert.AreEqual(2, SchemeImpl.Div0(-17, -11)); }
public void TestDiv0NP() { Assert.AreEqual(-2, SchemeImpl.Div0(-17, 11)); }
public void TestDiv0PN() { Assert.AreEqual(-2, SchemeImpl.Div0(17, -11)); }
public void TestDiv0PP() { Assert.AreEqual(2, SchemeImpl.Div0(17, 11)); }