Examples of signum()


Examples of java.math.BigInteger.signum()

                return n.signum() >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE;
            return number(n.shiftLeft(count));
        }
        if (second instanceof Bignum) {
            BigInteger count = ((Bignum)second).getValue();
            if (count.signum() > 0)
                throw new ConditionThrowable(new LispError("can't represent result of left shift"));
            if (count.signum() < 0)
                return n.signum() >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE;
            Debug.bug(); // Shouldn't happen.
        }
View Full Code Here

Examples of java.math.BigInteger.signum()

        }
        if (second instanceof Bignum) {
            BigInteger count = ((Bignum)second).getValue();
            if (count.signum() > 0)
                throw new ConditionThrowable(new LispError("can't represent result of left shift"));
            if (count.signum() < 0)
                return n.signum() >= 0 ? Fixnum.ZERO : Fixnum.MINUS_ONE;
            Debug.bug(); // Shouldn't happen.
        }
        throw new ConditionThrowable(new TypeError(second, "integer"));
    }
View Full Code Here

Examples of java.math.BigInteger.signum()

            BigInteger divisor = ((Fixnum)obj).getBigInteger();
            BigInteger[] results = value.divideAndRemainder(divisor);
            BigInteger quotient = results[0];
            BigInteger remainder = results[1];
            values[0] = number(quotient);
            values[1] = (remainder.signum() == 0) ? Fixnum.ZERO : number(remainder);
    } else if (obj instanceof Bignum) {
            BigInteger divisor = ((Bignum)obj).getValue();
            BigInteger[] results = value.divideAndRemainder(divisor);
            BigInteger quotient = results[0];
            BigInteger remainder = results[1];
View Full Code Here

Examples of java.math.BigInteger.signum()

            BigInteger divisor = ((Bignum)obj).getValue();
            BigInteger[] results = value.divideAndRemainder(divisor);
            BigInteger quotient = results[0];
            BigInteger remainder = results[1];
            values[0] = number(quotient);
            values[1] = (remainder.signum() == 0) ? Fixnum.ZERO : number(remainder);
    } else if (obj instanceof Ratio) {
            Ratio divisor = (Ratio) obj;
            LispObject quotient =
        multiplyBy(divisor.DENOMINATOR()).truncate(divisor.NUMERATOR());
            LispObject remainder =
View Full Code Here

Examples of java.math.BigInteger.signum()

                && r.getUpper().compareTo(messageNumber) >= 0) {
                done = true;
                break;
            } else {
                BigInteger diff = r.getLower().subtract(messageNumber);
                if (diff.signum() == 1) {
                    if (diff.equals(BigInteger.ONE)) {
                        r.setLower(messageNumber);
                        done = true;
                    }
                    break;
View Full Code Here

Examples of java.math.BigInteger.signum()

            n = ((Bignum)second).getValue();
        else
            throw new ConditionThrowable(new TypeError(second, "integer"));
        // FIXME See above.
        if (index == Integer.MAX_VALUE)
            return n.signum() < 0 ? T : NIL;
        return n.testBit(index) ? T : NIL;
    }

    private static final logbitp LOGBITP = new logbitp("logbitp");
}
View Full Code Here

Examples of java.math.BigInteger.signum()

            throw getRuntime().newZeroDivisionError();
        }

        BigInteger[] results = value.divideAndRemainder(otherValue);

        if ((value.signum() * otherValue.signum()) == -1 && results[1].signum() != 0) {
            return bignorm(getRuntime(), results[0].subtract(BigInteger.ONE));
        }
        return bignorm(getRuntime(), results[0]);
    }

View Full Code Here

Examples of java.math.BigInteger.signum()

            throw getRuntime().newZeroDivisionError();
        }

        BigInteger[] results = value.divideAndRemainder(otherValue);

        if ((value.signum() * otherValue.signum()) == -1 && results[1].signum() != 0) {
            results[0] = results[0].subtract(BigInteger.ONE);
            results[1] = otherValue.add(results[1]);
      }
        final Ruby runtime = getRuntime();
        return RubyArray.newArray(getRuntime(), bignorm(runtime, results[0]), bignorm(runtime, results[1]));
View Full Code Here

Examples of java.math.BigInteger.signum()

        }
        if (otherValue.equals(BigInteger.ZERO)) {
            throw getRuntime().newZeroDivisionError();
        }
        BigInteger result = value.mod(otherValue.abs());
        if (otherValue.signum() == -1 && result.signum() != 0) {
            result = otherValue.add(result);
        }
        return bignorm(getRuntime(), result);

            }
View Full Code Here

Examples of java.math.BigInteger.signum()

        }
    }
   
    private static final byte[] getBignumBytes(RubyBignum arg, int base, boolean sign, boolean upper) {
        BigInteger val = arg.getValue();
        if (sign || base == 10 || val.signum() >= 0) {
            return stringToBytes(val.toString(base),upper);
        }

        // negative values
        byte[] bytes = val.toByteArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.