當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。