Package java.math

Examples of java.math.BigInteger.remainder()


    long timeout;
    int nanos;
    if (nanosecondsObject instanceof BigInteger) {
      final BigInteger nanoseconds = (BigInteger) nanosecondsObject;
      timeout = nanoseconds.divide(ONE_MILLION).longValue();
      nanos = nanoseconds.remainder(ONE_MILLION).intValue();
    } else if (nanosecondsObject instanceof Integer) {
      final int nanoseconds = (Integer) nanosecondsObject;
      timeout = nanoseconds / 1000000;
      nanos = nanoseconds % 1000000;
    } else {
View Full Code Here


        while (true)
        {
            // Do cheap "pre-test" if applicable
            if (result.bitLength() > 6)
            {
                long r = result.remainder(
                    BigInteger.valueOf(SMALL_PRIME_PRODUCT)).longValue();
                if ((r % 3 == 0) || (r % 5 == 0) || (r % 7 == 0)
                    || (r % 11 == 0) || (r % 13 == 0) || (r % 17 == 0)
                    || (r % 19 == 0) || (r % 23 == 0) || (r % 29 == 0)
                    || (r % 31 == 0) || (r % 37 == 0) || (r % 41 == 0))
View Full Code Here

        BigInteger r = n.divide(TWO);
        if (n.remainder(TWO).equals(BigInteger.ONE)) {
            out.println(r);
        } else {
            r = r.subtract(BigInteger.ONE);
            if (r.remainder(TWO).equals(BigInteger.ZERO)) {
                r = r.subtract(BigInteger.ONE);
            }
            out.println(r);
        }
        out.flush();
View Full Code Here

        for (int i = 0; i < n; ++ i) {
            long a = in.nextInt();
            long b = in.nextInt();
            total = total.add(BigInteger.valueOf(a * b * 10000));
        }
        total = total.remainder(length);
        long result = total.longValue();
        result = Math.min(result, length.longValue() - result);
        out.printf("%d.%04d\n", result / 10000, result % 10000);
        out.flush();
    }
View Full Code Here

            for (int i = 0; i < m; ++ i) {
                if ((mask >> i & 1) == 1) {
                    sum = sum.add(products[i].multiply(inverses[i]));
                }
            }
            sum = sum.remainder(base.multiply(BigInteger.valueOf(b)));
            if (sum.compareTo(base) >= 0) {
                result.add(sum);
            }
        }
        if (n == 1) {
View Full Code Here

        }
        for (int i = 0; i < result.size(); ++ i) {
            BigInteger a = result.get(i);
            ArrayList <Integer> buffer = new ArrayList <Integer>();
            while (a.compareTo(BigInteger.ZERO) > 0) {
                buffer.add((int)a.remainder(BigInteger.valueOf(b)).longValue());
                a = a.divide(BigInteger.valueOf(b));
            }
            for (int j = n - 1; j >= 0; -- j) {
                int d = buffer.get(j);
                out.printf("%c", d < 10? '0' + d: 'A' + d - 10);
View Full Code Here

    private static int calculateControlDigitMod8(BigInteger number)
    {

        BigInteger sum = calculateControlDigitSum(number);

        int rem = sum.remainder(BigInteger.valueOf(11)).intValue();

        if ((rem == 0) || (rem == 1)) {

            return 0;
        }
View Full Code Here

     */
    public void setFractionalSecond(BigDecimal fractional) {
        calendarValue = null;
        second = fractional.intValue();
        BigInteger micros = fractional.movePointRight(6).toBigInteger();
        micros = micros.remainder(BigInteger.valueOf(1000000));
        microsecond = micros.intValue();
    }

    /**
     * <p>Return high order component for XML Schema 1.0 dateTime datatype field for
View Full Code Here

     *                                  in <a href="#datetimefieldmapping">date/time field mapping table</a>.
     */
    public void setFractionalSecond(BigDecimal fractional) {
        second = fractional.intValue();
        BigInteger micros = fractional.movePointRight(6).toBigInteger();
        micros = micros.remainder(BigInteger.valueOf(1000000));
        microsecond = micros.intValue();
    }

    /**
     * <p>Return high order component for XML Schema 1.0 dateTime datatype field for
View Full Code Here

                    }
                }
                if (!n.equals(MINUS_ONE))
                    for (int j = 0, size = array0 / d; j < size; j++) {
                        n = n.add(array[i]);
                        int p = intValue(n.remainder(array[0]));
                        if (!ns[p].equals(MINUS_ONE) && (ns[p].compareTo(n) < 0 || n.equals(MINUS_ONE)))
                            n = ns[p];
                        ns[p] = n;
                    }
            }
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.