Exemplo n.º 1
0
        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));
                }
            }
        }
Exemplo n.º 2
0
        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));
                }
            }
        }
Exemplo n.º 3
0
Arquivo: Logical.cs Projeto: vic/ioke
        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);
                }
            }
        }
Exemplo n.º 4
0
Arquivo: Logical.cs Projeto: vic/ioke
        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);
                }
            }
        }