本文整理汇总了C#中HugeInt.Import方法的典型用法代码示例。如果您正苦于以下问题:C# HugeInt.Import方法的具体用法?C# HugeInt.Import怎么用?C# HugeInt.Import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HugeInt
的用法示例。
在下文中一共展示了HugeInt.Import方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntImportExport
public void IntImportExport()
{
using (var a = new HugeInt("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"))
using (var b = new HugeInt())
{
var bytes = new byte[1000];
foreach (var order in Enum.GetValues(typeof(LimbOrder)).Cast<LimbOrder>())
foreach (var endianness in Enum.GetValues(typeof(Endianness)).Cast<Endianness>())
foreach (var nails in new[] { 0, 5, 10, 16 })
foreach (var size in new[] { 8, 11, 16 })
{
var words = a.Export(bytes, size, order, endianness, nails);
var expected = (ulong)System.Math.Ceiling(193m / (size * 8 - nails));
Assert.AreEqual(expected, words);
b.SetTo(0);
b.Import(bytes, words, size, order, endianness, nails);
Assert.AreEqual(a, b);
}
}
}
示例2: IntImportExportAllocating
public void IntImportExportAllocating()
{
using (var a = new HugeInt("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"))
using (var b = new HugeInt())
{
foreach (var order in Enum.GetValues(typeof(LimbOrder)).Cast<LimbOrder>())
foreach (var endianness in Enum.GetValues(typeof(Endianness)).Cast<Endianness>())
foreach (var nails in new[] { 0, 5, 10, 16 })
foreach (var size in new[] { 8, 11, 16 })
{
var bytes = a.Export<byte>(size, order, endianness, nails);
var expected = (int)System.Math.Ceiling(193m / (size * 8 - nails));
Assert.AreEqual(expected, bytes.Length / size);
b.SetTo(0);
b.Import(bytes, (uint)(bytes.Length / size), size, order, endianness, nails);
Assert.AreEqual(a, b);
}
}
}
示例3: IntImportExportAllocatingZero
public void IntImportExportAllocatingZero()
{
using (var a = new HugeInt())
using (var b = new HugeInt())
{
var order = LimbOrder.LeastSignificantFirst;
var endianness = Endianness.Native;
var nails = 5;
var size = 4;
var bytes = a.Export<byte>(size, order, endianness, nails);
Assert.AreEqual(0, bytes.Length);
b.SetTo(1);
b.Import(bytes, 0, size, order, endianness, nails);
Assert.AreEqual(a, b);
}
}