本文整理汇总了C#中HugeInt.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# HugeInt.CompareTo方法的具体用法?C# HugeInt.CompareTo怎么用?C# HugeInt.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HugeInt
的用法示例。
在下文中一共展示了HugeInt.CompareTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RationalCompareToHugeInt
public void RationalCompareToHugeInt()
{
using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
using (var b = new HugeInt("115756986668303657898962467957"))
using (var c = new HugeRational("115756986668303657898962467957/1"))
using (var d = new HugeInt(1922215141))
{
Assert.AreEqual(-1, System.Math.Sign(a.CompareTo(d)));
Assert.AreEqual(1, System.Math.Sign((-a).CompareTo(d)));
Assert.AreEqual(-1, System.Math.Sign((-a).CompareTo(d + 1)));
Assert.AreEqual(1, System.Math.Sign(d.CompareTo(a)));
Assert.AreEqual(-1, System.Math.Sign(d.CompareTo(-a)));
Assert.AreEqual(1, System.Math.Sign((d + 1).CompareTo(-a)));
Assert.AreEqual(0, System.Math.Sign(b.CompareTo(c)));
Assert.AreEqual(0, System.Math.Sign(c.CompareTo(b)));
Assert.AreEqual(0, System.Math.Sign((-b).CompareTo(-c)));
Assert.AreEqual(0, System.Math.Sign((-c).CompareTo(-b)));
Assert.AreEqual(1, System.Math.Sign(b.CompareTo(c - 1)));
Assert.AreEqual(1, System.Math.Sign(c.CompareTo(b - 1)));
Assert.AreEqual(-1, System.Math.Sign((-b).CompareTo(1 - c)));
Assert.AreEqual(-1, System.Math.Sign((-c).CompareTo(1 - b)));
}
}