本文整理汇总了C#中HugeInt.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HugeInt.ToString方法的具体用法?C# HugeInt.ToString怎么用?C# HugeInt.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HugeInt
的用法示例。
在下文中一共展示了HugeInt.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntComplementBit
public void IntComplementBit()
{
using (var a = new HugeInt("0xA0000000000000000000800000000001"))
{
a.ComplementBit(46);
Assert.AreEqual("A0000000000000000000C00000000001", a.ToString(16));
a.ComplementBit(47);
Assert.AreEqual("A0000000000000000000400000000001", a.ToString(16));
a.ComplementBit(131);
Assert.AreEqual("8A0000000000000000000400000000001", a.ToString(16));
}
}
示例2: IntPowerLimb
public void IntPowerLimb()
{
using (var a = new HugeInt("9785412309485720938412983404349"))
{
a.Value = a ^ 4;
Assert.AreEqual("9168884832199547717402442404668238841010784738902226284286664833331445628675177089723224507720724521226586825967635414667601", a.ToString());
}
}
示例3: IntCompoundOperators
public void IntCompoundOperators()
{
using (var a = new HugeInt("938475092834705928347523452345"))
{
a.Value += 1;
a.Value *= 10;
Assert.AreEqual("9384750928347059283475234523460", a.ToString());
}
}
示例4: IntAssignRational
public void IntAssignRational()
{
using (var a = new HugeRational("222509832503450298345029835740293845720/7"))
using (var b = new HugeInt())
{
b.SetTo(a);
Assert.AreEqual("31787118929064328335004262248613406531", b.ToString());
}
}
示例5: IntAssignCopy
public void IntAssignCopy()
{
using (var a = new HugeInt("-222509832503450298345029835740293845720"))
using (var b = new HugeInt())
{
b.Value = a;
Assert.AreEqual("-222509832503450298345029835740293845720", b.ToString());
}
}
示例6: IntAddLimb
public void IntAddLimb()
{
using (var a = new HugeInt("222509832503450298345029835740293845720"))
{
var b = Platform.Ui(4288574029879874539UL, 4288574029U);
a.Value = a + b;
Assert.AreEqual(Platform.Select("222509832503450298349318409770173720259", "222509832503450298345029835744582419749"), a.ToString());
}
}
示例7: IntAndHugeInt
public void IntAndHugeInt()
{
using (var a = new HugeInt("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"))
using (var b = new HugeInt("0x100000000000000000123456789ABCDEFFFFFFFFFFFFFFFFF"))
using (var c = new HugeInt())
{
c.Value = a & b;
Assert.AreEqual("100000000000000000123456789ABCDEF0123456789ABCDEF", c.ToString(16));
}
}
示例8: IntAddHugeInt
public void IntAddHugeInt()
{
using (var a = new HugeInt("222509832503450298345029835740293845720"))
using (var b = new HugeInt("222987435987982730594288574029879874539"))
using (var c = new HugeInt())
{
c.Value = a + b;
Assert.AreEqual("445497268491433028939318409770173720259", c.ToString());
}
}
示例9: IntAddProductHugeInt
public void IntAddProductHugeInt()
{
using (var a = new HugeInt("98750293847520938457029384572093480498357"))
using (var c = new HugeInt("23094582093845093574093845093485039450934"))
using (var b = new HugeInt("-394580293847502987609283945873594873409587"))
{
var expr = a + c*b;
a.Value = expr;
Assert.AreEqual("-9112666988874677841199955832262586145147830205230375090322356322089362221491205901", a.ToString());
}
}
示例10: IntSwap
public void IntSwap()
{
var strA = "-222509832503450298345029835740293845720";
var strB = "2039847290878794872059384789347534534";
using (var a = new HugeInt(strA))
using (var b = new HugeInt(strB))
{
var aValue = a._value();
var bValue = b._value();
a.Swap(b);
Assert.AreEqual(aValue, a._value());
Assert.AreEqual(bValue, b._value());
Assert.AreEqual(strA, b.ToString());
Assert.AreEqual(strB, a.ToString());
}
}
示例11: IntFactorial
public void IntFactorial()
{
using (var a = new HugeInt(HugeInt.Factorial(30)))
using (var b = new HugeInt("50"))
using (var c = new HugeInt("70"))
using (var x = new HugeInt())
{
for (x.Value = b - 2; x > 0; x.Value -= 2)
b.Value *= x;
for (x.Value = c - 3; x > 0; x.Value -= 3)
c.Value *= x;
Assert.AreEqual("265252859812191058636308480000000", a.ToString());
Assert.AreEqual(b, HugeInt.Factorial(50, 2));
Assert.AreEqual(c, HugeInt.Factorial(70, 3));
}
}
示例12: RoundingMode
public void RoundingMode()
{
const string strA = "9520398475029834502983475028934705982734095827304958723409758230498573034928750938475987498473958743";
var down = strA.Substring(0, strA.Length - 1);
var up = strA.Substring(0, strA.Length - 2) + (char) (strA[strA.Length - 2] + 1);
using (var a = new HugeInt(strA))
using (var b = new HugeInt())
{
Assert.AreEqual(RoundingModes.Truncate, MpirSettings.RoundingMode);
b.Value = a / 10;
Assert.AreEqual(down, b.ToString());
b.Value = -a / 10;
Assert.AreEqual("-" + down, b.ToString());
MpirSettings.RoundingMode = RoundingModes.Default;
b.Value = a / 10;
Assert.AreEqual(down, b.ToString());
b.Value = -a / 10;
Assert.AreEqual("-" + down, b.ToString());
MpirSettings.RoundingMode = RoundingModes.Floor;
b.Value = a / 10;
Assert.AreEqual(down, b.ToString());
b.Value = -a / 10;
Assert.AreEqual("-" + up, b.ToString());
MpirSettings.RoundingMode = RoundingModes.Ceiling;
b.Value = a / 10;
Assert.AreEqual(up, b.ToString());
b.Value = -a / 10;
Assert.AreEqual("-" + down, b.ToString());
MpirSettings.RoundingMode = RoundingModes.Truncate;
}
}
示例13: IntToAndFromInt
public void IntToAndFromInt()
{
using (var a = new HugeInt())
{
int b = -0x784739AB;
a.SetTo(b);
Assert.AreEqual(b.ToString(), a.ToString());
long c = a.ToInt();
Assert.AreEqual(b.ToString(), c.ToString());
}
}
示例14: IntSquareRoot
public void IntSquareRoot()
{
var n = "8984948281360922385394772450147012613851354303";
using (var a = new HugeInt(n))
using (var b = new HugeInt())
using (var c = new HugeInt())
{
a.Value = a * a;
b.Value = a.SquareRoot();
Assert.AreEqual(n, b.ToString());
b.SetTo(0);
b.Value = (a + 123).SquareRoot().SavingRemainderTo(c);
Assert.AreEqual(n, b.ToString());
Assert.AreEqual("123", c.ToString());
}
}
示例15: IntRoot
public void IntRoot()
{
var n = "8984948281360922385394772450147012613851354303";
using (var a = new HugeInt(n))
using (var b = new HugeInt())
using (var c = new HugeInt())
{
a.Value = a * a * a;
b.Value = a.Root(3);
Assert.AreEqual(n, b.ToString());
bool exact = false;
b.Value = a.Root(3).SettingExactTo(x => exact = x);
Assert.AreEqual(n, b.ToString());
Assert.IsTrue(exact);
b.Value = (a + 123).Root(3).SettingExactTo(x => exact = x);
Assert.AreEqual(n, b.ToString());
Assert.IsFalse(exact);
b.Value = (a + 123).Root(3).SavingRemainderTo(c);
Assert.AreEqual(n, b.ToString());
Assert.AreEqual("123", c.ToString());
}
}