当前位置: 首页>>代码示例>>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;未经允许,请勿转载。