public void RationalEqualsLimb() { using (var a = new HugeRational(Platform.Select("222509832503", "2225098323"))) { var b = Platform.Ui(222509832504, 2225098324); Assert.IsFalse(a.Equals(b + 1)); Assert.IsTrue(a.Equals(b - 1)); Assert.IsTrue((a + 1).Equals(b)); } }
public void RationalEqualsSignedLimb() { using (var a = new HugeRational(Platform.Select("-222509832505", "-222509835"))) { var b = Platform.Si(-222509832504, -222509834); Assert.IsFalse(a.Equals(b + 1)); Assert.IsTrue(a.Equals(b - 1)); Assert.IsTrue((a + 1).Equals(b)); } }
public void RationalEqualsLimb2() { using (var a = new HugeRational(Platform.Select("222509832377/127", "2509832377/127"))) { var b = Platform.Ui(222509832504, 2509832504); uint d = 127; Assert.IsFalse(a.Equals(b + 1, d)); Assert.IsTrue(a.Equals(b - d, d)); Assert.IsTrue((a + 1).Equals(b, d)); } }
public void RationalEqualsSignedLimb2() { using (var a = new HugeRational(Platform.Select("-222509832377/127", "-1509832377/127"))) { var b = Platform.Si(-222509832504, -1509832504); uint d = 127; Assert.IsFalse(a.Equals(b + 1, d)); Assert.IsTrue(a.Equals(b + (int)d, d)); Assert.IsTrue((a - 1).Equals(b, d)); } }
public void RationalEqualsDouble() { using (var a = new HugeRational("-222509832505")) { double b = -222509832504; Assert.IsFalse(a.Equals(b + 1)); Assert.IsTrue(a.Equals(b - 1)); Assert.IsTrue((a + 1).Equals(b)); Assert.IsFalse((a + 1).Equals(b + 0.1)); } }
public void RationalEqualsHugeRational() { using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957")) using (var b = new HugeRational("222509832503450298345029835740293845720/115756986668303657898962467957")) using (var c = new HugeRational("1/115756986668303657898962467957")) { Assert.IsFalse(b.Equals(a)); Assert.IsFalse(a.Equals(b + c)); Assert.IsTrue((a + c).Equals(-b)); Assert.IsFalse(a.Equals(null)); Assert.IsTrue(Equals(a + c, -b)); } }
public void RationalEqualsNonExpression() { using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957")) { Assert.IsFalse(a.Equals("abc")); } }
public void RationalEqualsHugeInt() { using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957")) using (var b = new HugeInt(1922215142)) using (var c = new HugeRational("115756986668303657898962467957/1")) using (var d = new HugeInt("-115756986668303657898962467957")) { Assert.IsFalse(a.Equals(b)); Assert.IsFalse(b.Equals(a)); Assert.IsFalse(a.Equals(-b)); Assert.IsFalse(b.Equals(-a)); Assert.IsFalse(c.Equals(d)); Assert.IsTrue(c.Equals(-d)); Assert.IsTrue((-c).Equals(d)); Assert.IsTrue(d.Equals(-c)); Assert.IsTrue((-d).Equals(c)); Assert.IsTrue(Equals(c, -d)); Assert.IsTrue(Equals(-c, d)); } }
public void RationalToAndFromDouble() { using (var a = new HugeRational()) { a.SetTo(-123.25); double c = a.ToDouble(); Assert.IsTrue(c.Equals(-123.25)); Assert.IsTrue(a.Equals(-123.25)); } }