当前位置: 首页>>代码示例>>C#>>正文


C# HugeInt.Import方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:wbhart,项目名称:mpir,代码行数:22,代码来源:IO.cs

示例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);
                            }
            }
        }
开发者ID:wbhart,项目名称:mpir,代码行数:20,代码来源:IO.cs

示例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);
            }
        }
开发者ID:wbhart,项目名称:mpir,代码行数:18,代码来源:IO.cs


注:本文中的HugeInt.Import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。