Package java.math

Examples of java.math.BigInteger.abs()


        int nbits = RubyNumeric.num2int(n);
        BigInteger val = this.value;
        if (val.signum() >= 0) {
            return newBN(getRuntime(), val.shiftLeft(nbits));
        } else {
            return newBN(getRuntime(), val.abs().shiftLeft(nbits).negate());
        }
    }

    @JRubyMethod(name=">>")
    public IRubyObject bn_rshift(IRubyObject n) {
View Full Code Here


        int nbits = RubyNumeric.num2int(n);
        BigInteger val = this.value;
        if (val.signum() >= 0) {
            return newBN(getRuntime(), val.shiftRight(nbits));
        } else {
            return newBN(getRuntime(), val.abs().shiftRight(nbits).negate());
        }
    }
   
    @JRubyMethod(name="num_bits")
    public IRubyObject bn_num_bits() {
View Full Code Here

    public static BigInteger hashToBigInteger(ByteBuffer data)
    {
        byte[] result = hash(data);
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(ByteBuffer... data)
    {
      byte[] result;
View Full Code Here

    public static BigInteger hash(String data)
    {
        byte[] result = hash("MD5", data.getBytes());
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(String type, byte[]... data)
    {
      byte[] result = null;
View Full Code Here

        BigInteger dividend = getBI(tc, a);
        BigInteger divisor = getBI(tc, b);
        long dividend_sign = dividend.signum();
        long divisor_sign = divisor.signum();
        if (dividend_sign * divisor_sign == -1) {
            if (dividend.mod(divisor.abs ()).compareTo(BigInteger.ZERO) != 0) {
                return makeBI(tc, type, dividend.divide(divisor).subtract(BigInteger.ONE));
            }
        }
        return makeBI(tc, type, dividend.divide(divisor));
    }
View Full Code Here

    public static BigInteger hashToBigInteger(ByteBuffer data)
    {
        byte[] result = hash(data);
        BigInteger hash = new BigInteger(result);
        return hash.abs();
    }

    public static byte[] hash(ByteBuffer... data)
    {
        MessageDigest messageDigest = localMD5Digest.get();
View Full Code Here

    public static BigInteger md5hash(ByteBuffer data)
    {
        byte[] result = hash("MD5", data);
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(String type, ByteBuffer... data)
    {
      byte[] result;
View Full Code Here

        }

        BigInteger year = xgc.getEonAndYear();
        if (year != null) {
            cal.set(Calendar.ERA, year.signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD);
            cal.set(Calendar.YEAR, year.abs().intValue());
        }

        if (xgc.getDay() != DatatypeConstants.FIELD_UNDEFINED)
            cal.set(Calendar.DAY_OF_MONTH, xgc.getDay());
View Full Code Here

    public static BigInteger hashToBigInteger(ByteBuffer data)
    {
        byte[] result = hash(data);
        BigInteger hash = new BigInteger(result);
        return hash.abs();       
    }

    public static byte[] hash(ByteBuffer... data)
    {
        MessageDigest messageDigest = localMD5Digest.get();
View Full Code Here

                result.set(Calendar.YEAR, Math.abs(year));
            }
            else {
                BigInteger eonAndYear = getEonAndYear();
                result.set(Calendar.ERA, eonAndYear.signum() == -1 ? GregorianCalendar.BC : GregorianCalendar.AD);
                result.set(Calendar.YEAR, eonAndYear.abs().intValue());
            }
        }

        // only set month if it is set
        if (month != DatatypeConstants.FIELD_UNDEFINED) {
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.