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


C# BigInteger.GetLowestSetBit方法代码示例

本文整理汇总了C#中BigInteger.GetLowestSetBit方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.GetLowestSetBit方法的具体用法?C# BigInteger.GetLowestSetBit怎么用?C# BigInteger.GetLowestSetBit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigInteger的用法示例。


在下文中一共展示了BigInteger.GetLowestSetBit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultiplyPositive

        /**
         * 'Zeroless' Signed Digit Left-to-Right.
         */
        protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
        {
            ECPoint addP = p.Normalize(), subP = addP.Negate();

            ECPoint R0 = addP;

            int n = k.BitLength;
            int s = k.GetLowestSetBit();

            int i = n;
            while (--i > s)
            {
                R0 = R0.TwicePlus(k.TestBit(i) ? addP : subP);
            }

            R0 = R0.TimesPow2(s);

            return R0;
        }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:22,代码来源:ZSignedDigitL2RMultiplier.cs

示例2: MultiplyPositive

        /**
         * 'Zeroless' Signed Digit Right-to-Left.
         */
        protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
        {
            ECPoint R0 = p.Curve.Infinity, R1 = p;

            int n = k.BitLength;
            int s = k.GetLowestSetBit();

            R1 = R1.TimesPow2(s);

            int i = s;
            while (++i < n)
            {
                R0 = R0.Add(k.TestBit(i) ? R1 : R1.Negate());
                R1 = R1.Twice();
            }

            R0 = R0.Add(R1);

            return R0;
        }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:23,代码来源:ZSignedDigitR2LMultiplier.cs

示例3: TestGetLowestSetBit

 public void TestGetLowestSetBit()
 {
     for (int i = 0; i < 10; ++i)
     {
         BigInteger test = new BigInteger(128, 0, Rnd).Add(One);
         int bit1 = test.GetLowestSetBit();
         Assert.AreEqual(test, test.ShiftRight(bit1).ShiftLeft(bit1));
         int bit2 = test.ShiftLeft(i + 1).GetLowestSetBit();
         Assert.AreEqual(i + 1, bit2 - bit1);
         int bit3 = test.ShiftLeft(13*i + 1).GetLowestSetBit();
         Assert.AreEqual(13*i + 1, bit3 - bit1);
     }
 }
开发者ID:ChemicalRocketeer,项目名称:BigMath,代码行数:13,代码来源:BigIntegerTest.cs

示例4: LucasSequence

        private BigInteger[] LucasSequence(
            BigInteger	P,
            BigInteger	Q,
            BigInteger	k)
        {
            // TODO Research and apply "common-multiplicand multiplication here"

            int n = k.BitLength;
            int s = k.GetLowestSetBit();

            Debug.Assert(k.TestBit(s));

            BigInteger Uh = BigInteger.One;
            BigInteger Vl = BigInteger.Two;
            BigInteger Vh = P;
            BigInteger Ql = BigInteger.One;
            BigInteger Qh = BigInteger.One;

            for (int j = n - 1; j >= s + 1; --j)
            {
                Ql = ModMult(Ql, Qh);

                if (k.TestBit(j))
                {
                    Qh = ModMult(Ql, Q);
                    Uh = ModMult(Uh, Vh);
                    Vl = ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
                    Vh = ModReduce(Vh.Multiply(Vh).Subtract(Qh.ShiftLeft(1)));
                }
                else
                {
                    Qh = Ql;
                    Uh = ModReduce(Uh.Multiply(Vl).Subtract(Ql));
                    Vh = ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
                    Vl = ModReduce(Vl.Multiply(Vl).Subtract(Ql.ShiftLeft(1)));
                }
            }

            Ql = ModMult(Ql, Qh);
            Qh = ModMult(Ql, Q);
            Uh = ModReduce(Uh.Multiply(Vl).Subtract(Ql));
            Vl = ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
            Ql = ModMult(Ql, Qh);

            for (int j = 1; j <= s; ++j)
            {
                Uh = ModMult(Uh, Vl);
                Vl = ModReduce(Vl.Multiply(Vl).Subtract(Ql.ShiftLeft(1)));
                Ql = ModMult(Ql, Ql);
            }

            return new BigInteger[] { Uh, Vl };
        }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:53,代码来源:ECFieldElement.cs


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