當前位置: 首頁>>代碼示例>>C#>>正文


C# BigInteger.ToInt32方法代碼示例

本文整理匯總了C#中BigInteger.ToInt32方法的典型用法代碼示例。如果您正苦於以下問題:C# BigInteger.ToInt32方法的具體用法?C# BigInteger.ToInt32怎麽用?C# BigInteger.ToInt32使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BigInteger的用法示例。


在下文中一共展示了BigInteger.ToInt32方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PowRound

 public static BigDecimal PowRound(BigDecimal x, BigInteger n)
 {
     /** For now, the implementation forwards to the cases where n
         * is in the range of the standard integers. This might, however, be
         * implemented to decompose larger powers into cascaded calls to smaller ones.
         */
     if (n.CompareTo(Rational.MaxInt32) > 0 ||
         n.CompareTo(Rational.MinInt32) < 0)
         throw new NotSupportedException("Big power for " + n + " not supported");
     return PowRound(x, n.ToInt32());
 }
開發者ID:tupunco,項目名稱:deveel-math,代碼行數:11,代碼來源:BigMath.cs

示例2: Jacobi

        /// <summary>
        /// Computes the value of the Jacobi symbol (A|B). 
        /// </summary>
        /// 
        /// <param name="A">The integer value</param>
        /// <param name="B">The integer value</param>
        /// 
        /// <returns>Returns value of the jacobi symbol (A|B)</returns>
        public static int Jacobi(BigInteger A, BigInteger B)
        {
            BigInteger a, b, v;
            long k = 1;

            // test trivial cases
            if (B.Equals(ZERO))
            {
                a = A.Abs();
                return a.Equals(ONE) ? 1 : 0;
            }

            if (!A.TestBit(0) && !B.TestBit(0))
                return 0;

            a = A;
            b = B;

            if (b.Signum() == -1)
            { // b < 0
                b = b.Negate();
                if (a.Signum() == -1)
                    k = -1;
            }

            v = ZERO;
            while (!b.TestBit(0))
            {
                v = v.Add(ONE);
                b = b.Divide(TWO);
            }

            if (v.TestBit(0))
                k = k * _jacobiTable[a.ToInt32() & 7];

            if (a.Signum() < 0)
            {
                if (b.TestBit(1))
                    k = -k;
                a = a.Negate();
            }

            // main loop
            while (a.Signum() != 0)
            {
                v = ZERO;
                while (!a.TestBit(0))
                { // a is even
                    v = v.Add(ONE);
                    a = a.Divide(TWO);
                }
                if (v.TestBit(0))
                    k = k * _jacobiTable[b.ToInt32() & 7];

                if (a.CompareTo(b) < 0)
                {
                    // swap and correct intermediate result
                    BigInteger x = a;
                    a = b;
                    b = x;
                    if (a.TestBit(1) && b.TestBit(1))
                        k = -k;
                }
                a = a.Subtract(b);
            }

            return b.Equals(ONE) ? (int)k : 0;
        }
開發者ID:Steppenwolfe65,項目名稱:Rainbow-NET,代碼行數:76,代碼來源:BigMath.cs

示例3: Next

        /// <summary>
        /// Get a pseudo random 32bit integer
        /// </summary>
        /// 
        /// <returns>Random Int32</returns>
        public Int32 Next()
        {
            // Xi+1 = (X pow 2) mod N
            _X = _X.Multiply(_X).Mod(_N);

            return _X.ToInt32();
        }
開發者ID:modulexcite,項目名稱:CEX,代碼行數:12,代碼來源:BBSG.cs


注:本文中的BigInteger.ToInt32方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。