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


C# BigInteger.equals方法代碼示例

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


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

示例1: and

        /** @see BigInteger#and(BigInteger) */
        internal static BigInteger and(BigInteger val, BigInteger that)
        {
            if (that.sign == 0 || val.sign == 0) {
                return BigInteger.ZERO;
            }
            if (that.equals(BigInteger.MINUS_ONE)){
                return val;
            }
            if (val.equals(BigInteger.MINUS_ONE)) {
                return that;
            }

            if (val.sign > 0) {
                if (that.sign > 0) {
                    return andPositive(val, that);
                } else {
                    return andDiffSigns(val, that);
                }
            } else {
                if (that.sign > 0) {
                    return andDiffSigns(that, val);
                } else if (val.numberLength > that.numberLength) {
                    return andNegative(val, that);
                } else {
                    return andNegative(that, val);
                }
            }
        }
開發者ID:sailesh341,項目名稱:JavApi,代碼行數:29,代碼來源:Logical.cs

示例2: xor

        /** @see BigInteger#xor(BigInteger) */
        internal static BigInteger xor(BigInteger val, BigInteger that)
        {
            if (that.sign == 0) {
                return val;
            }
            if (val.sign == 0) {
                return that;
            }
            if (that.equals(BigInteger.MINUS_ONE)) {
                return val.not();
            }
            if (val.equals(BigInteger.MINUS_ONE)) {
                return that.not();
            }

            if (val.sign > 0) {
                if (that.sign > 0) {
                    if (val.numberLength > that.numberLength) {
                        return xorPositive(val, that);
                    } else {
                        return xorPositive(that, val);
                    }
                } else {
                    return xorDiffSigns(val, that);
                }
            } else {
                if (that.sign > 0) {
                    return xorDiffSigns(that, val);
                } else if (that.getFirstNonzeroDigit() > val.getFirstNonzeroDigit()) {
                    return xorNegative(that, val);
                } else {
                    return xorNegative(val, that);
                }
            }
        }
開發者ID:sailesh341,項目名稱:JavApi,代碼行數:36,代碼來源:Logical.cs

示例3: not

        /** @see BigInteger#not() */
        internal static BigInteger not(BigInteger val)
        {
            if (val.sign == 0) {
                return BigInteger.MINUS_ONE;
            }
            if (val.equals(BigInteger.MINUS_ONE)) {
                return BigInteger.ZERO;
            }
            int []resDigits = new int[val.numberLength + 1];
            int i;

            if (val.sign > 0) {
                // ~val = -val + 1
                if (val.digits[val.numberLength - 1] != -1) {
                    for (i = 0; val.digits[i] == -1; i++) {
                        ;
                    }
                } else {
                    for (i = 0; (i < val.numberLength) && (val.digits[i] == -1); i++) {
                        ;
                    }
                    if (i == val.numberLength) {
                        resDigits[i] = 1;
                        return new BigInteger(-val.sign, i + 1, resDigits);
                    }
                }
                // Here a carry 1 was generated
            } else {// (val.sign < 0)
                // ~val = -val - 1
                for (i = 0; val.digits[i] == 0; i++) {
                    resDigits[i] = -1;
                }
                // Here a borrow -1 was generated
            }
            // Now, the carry/borrow can be absorbed
            resDigits[i] = val.digits[i] + val.sign;
            // Copying the remaining unchanged digit
            for (i++; i < val.numberLength; i++) {
                resDigits[i] = val.digits[i];
            }
            return new BigInteger(-val.sign, i, resDigits);
        }
開發者ID:sailesh341,項目名稱:JavApi,代碼行數:43,代碼來源:Logical.cs

示例4: andNot

        /** @see BigInteger#andNot(BigInteger) */
        internal static BigInteger andNot(BigInteger val, BigInteger that)
        {
            if (that.sign == 0 ) {
                return val;
            }
            if (val.sign == 0) {
                return BigInteger.ZERO;
            }
            if (val.equals(BigInteger.MINUS_ONE)) {
                return that.not();
            }
            if (that.equals(BigInteger.MINUS_ONE)){
                return BigInteger.ZERO;
            }

            //if val == that, return 0

               if (val.sign > 0) {
                if (that.sign > 0) {
                    return andNotPositive(val, that);
                } else {
                    return andNotPositiveNegative(val, that);
                        }
                    } else {
                if (that.sign > 0) {
                    return andNotNegativePositive(val, that);
                } else  {
                    return andNotNegative(val, that);
                }
            }
        }
開發者ID:sailesh341,項目名稱:JavApi,代碼行數:32,代碼來源:Logical.cs


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