• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IntX类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IntX的典型用法代码示例。如果您正苦于以下问题:C# IntX类的具体用法?C# IntX怎么用?C# IntX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IntX类属于命名空间,在下文中一共展示了IntX类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Add2BigIntXC3

 public void Add2BigIntXC3()
 {
     IntX int1 = new IntX(new uint[] { uint.MaxValue, uint.MaxValue }, false);
     IntX int2 = new IntX(new uint[] { 1, 1 }, false);
     IntX int3 = new IntX(new uint[] { 0, 1, 1 }, false);
     Assert.IsTrue(int1 + int2 == int3);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:AddOpTest.cs


示例2: Simple

 public void Simple()
 {
     IntX int1 = new IntX(8);
     int1 *= int1;
     int1.Normalize();
     Assert.IsTrue(int1 == 64);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:NormalizeTest.cs


示例3: Sub2BigIntXC4

 public void Sub2BigIntXC4()
 {
     IntX int1 = new IntX(new uint[] { uint.MaxValue, uint.MaxValue, 1, 1 }, false);
     IntX int2 = new IntX(new uint[] { 1, 1 }, false);
     IntX int3 = new IntX(new uint[] { 0, 1, 2, 1 }, false);
     Assert.IsTrue(int1 == int3 - int2);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:SubOpTest.cs


示例4: Big

 public void Big()
 {
     IntX int1 = new IntX(new uint[] {0, 0, 0x80000000U, 0x7fffffffU}, false);
     IntX int2 = new IntX(new uint[] {1, 0, 0x80000000U}, false);
     IntX intM = new IntX(new uint[] {2, 0xffffffffU, 0x7fffffffU}, false);
     Assert.IsTrue(int1 % int2 == intM);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:ModOpTest.cs


示例5: Add2BigIntX

 public void Add2BigIntX()
 {
     IntX int1 = new IntX(new uint[] { 1, 2, 3 }, false);
     IntX int2 = new IntX(new uint[] { 3, 4, 5 }, false);
     IntX int3 = new IntX(new uint[] { 4, 6, 8 }, false);
     Assert.IsTrue(int1 + int2 == int3);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:AddOpTest.cs


示例6: Big

 public void Big()
 {
     IntX int1   = new IntX(new uint[] { 1, 1 }, false);
     IntX int2   = new IntX(new uint[] { 1, 1 }, false);
     IntX intRes = new IntX(new uint[] { 1, 2, 1 }, false);
     Assert.AreEqual(int1 * int2, intRes);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:MulOpTest.cs


示例7: Multiply

        /// <summary>
        /// Multiplies two big integers.
        /// </summary>
        /// <param name="int1">First big integer.</param>
        /// <param name="int2">Second big integer.</param>
        /// <returns>Resulting big integer.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="int1" /> or <paramref name="int2" /> is a null reference.</exception>
        /// <exception cref="ArgumentException"><paramref name="int1" /> or <paramref name="int2" /> is too big for multiply operation.</exception>
        public virtual IntX Multiply(IntX int1, IntX int2)
        {
            // Exceptions
            if (ReferenceEquals(int1, null))
            {
                throw new ArgumentNullException("int1", Strings.CantBeNull);
            }
            else if (ReferenceEquals(int2, null))
            {
                throw new ArgumentNullException("int2", Strings.CantBeNull);
            }

            // Special behavior for zero cases
            if (int1._length == 0 || int2._length == 0) return new IntX();

            // Get new big integer length and check it
            ulong newLength = (ulong)int1._length + int2._length;
            if (newLength >> 32 != 0)
            {
                throw new ArgumentException(Strings.IntegerTooBig);
            }

            // Create resulting big int
            IntX newInt = new IntX((uint)newLength, int1._negative ^ int2._negative);

            // Perform actual digits multiplication
            newInt._length = Multiply(int1._digits, int1._length, int2._digits, int2._length, newInt._digits);

            // Normalization may be needed
            newInt.TryNormalize();

            return newInt;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:41,代码来源:MultiplierBase.cs


示例8: gcd

 //Old GCD algorithm.
 public static IntX gcd(IntX a, IntX b) {
   if(b == 0) {
     return a;
   }else {
     return gcd(b, a % b);
   }
 }
开发者ID:CMPS112-RSA,项目名称:cmps112-project,代码行数:8,代码来源:keygen_csharp.cs


示例9: Big3

 public void Big3()
 {
     IntX int1   = new IntX(new uint[] { uint.MaxValue, uint.MaxValue }, false);
     IntX int2   = new IntX(new uint[] { uint.MaxValue, uint.MaxValue }, false);
     IntX intRes = new IntX(new uint[] { 1, 0, uint.MaxValue - 1, uint.MaxValue }, false);
     Assert.IsTrue(int1 * int2 == intRes);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:MulOpTest.cs


示例10: Sub2BigIntX

 public void Sub2BigIntX()
 {
     IntX int1 = new IntX(new uint[] { 1, 2, 3 }, false);
     IntX int2 = new IntX(new uint[] { 3, 4, 5 }, false);
     IntX int3 = new IntX(new uint[] { 2, 2, 2 }, true);
     Assert.IsTrue(int1 - int2 == int3);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:SubOpTest.cs


示例11: Add0IntXNeg

 public void Add0IntXNeg()
 {
     IntX int1 = new IntX(-3);
     Assert.IsTrue(int1 + 0 == -3);
     Assert.IsTrue(int1 + new IntX() == -3);
     Assert.IsTrue(new IntX(0) + new IntX(-1) == -1);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:7,代码来源:AddOpTest.cs


示例12: ShouldBeFalseForZero

        public void ShouldBeFalseForZero()
        {
            IntX value = new IntX();

            bool result = value.IsOdd;

            Assert.That(result, Is.False);
        }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:IsOddTest.cs


示例13: genN

  //Generates p, q, and n.  Returns an array of p, q, and n in that order.
  public static IntX[] genN() {
    IntX[] output = new IntX[3];
    output[0] = genRandPrime();
    output[1] = genRandPrime();
    output[2] = output[0] * output[1];

    return output;
  }
开发者ID:CMPS112-RSA,项目名称:cmps112-project,代码行数:9,代码来源:keygen_csharp.cs


示例14: Performance

 public void Performance()
 {
     IntX intX  = new IntX(new uint[] { 0, 1 }, false);
     IntX intX2 = intX;
     for (int i = 0; i < 1000; ++i) {
         intX2 *= intX;
     }
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:MulOpTest.cs


示例15: Big2

 public void Big2()
 {
     IntX int1   = new IntX(new uint[] { 1, 1 }, false);
     IntX int2   = new IntX(new uint[] { 2 }, false);
     IntX intRes = new IntX(new uint[] { 2, 2 }, false);
     Assert.AreEqual(intRes, int1 * int2);
     Assert.AreEqual(intRes, int2 * int1);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:MulOpTest.cs


示例16: ShouldBeTrueForOddNumber

        public void ShouldBeTrueForOddNumber()
        {
            IntX value = new IntX(57);

            bool result = value.IsOdd;

            Assert.That(result, Is.True);
        }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:IsOddTest.cs


示例17: ShouldBeFalseForEvenNumber

        public void ShouldBeFalseForEvenNumber()
        {
            IntX value = new IntX(42);

            bool result = value.IsOdd;

            Assert.That(result, Is.False);
        }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:IsOddTest.cs


示例18: Sub0IntXNeg

 public void Sub0IntXNeg()
 {
     IntX int1 = new IntX(-3);
     Assert.IsTrue(int1 - 0 == -3);
     Assert.IsTrue(0 - int1 == 3);
     Assert.IsTrue(int1 - new IntX() == -3);
     Assert.IsTrue(new IntX() - int1 == 3);
 }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:SubOpTest.cs


示例19: ShouldOnesComplementZero

        public void ShouldOnesComplementZero()
        {
            IntX value = new IntX();

            IntX result = ~value;

            Assert.That(result, Is.EqualTo(0));
        }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:OnesComplementOpTest.cs


示例20: ShouldOnesComplementBigIntX

        public void ShouldOnesComplementBigIntX()
        {
            IntX value = new IntX(new uint[] { 3, 5, uint.MaxValue }, false);

            IntX result = ~value;

            Assert.That(result, Is.EqualTo(new IntX(new uint[] { ~(uint)3, ~(uint)5 }, true)));
        }
开发者ID:devoyster,项目名称:IntXLib,代码行数:8,代码来源:OnesComplementOpTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Integer类代码示例发布时间:2022-05-24
下一篇:
C# IntVector3类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap