Package java.math

Examples of java.math.BigInteger.divide()


        if (values.size() % 2 == 1)
          return values.get(values.size() / 2);
        BigInteger bi = BigInteger.valueOf(values.get(
                values.size() / 2 - 1));
        bi = bi.add(BigInteger.valueOf(values.get(values.size() / 2)));
        return bi.divide(BigInteger.valueOf(2)).shortValue();
      case MODE:
        Hashtable<Integer, Integer> map =
            new Hashtable<Integer, Integer>();
        for (int i = 0; i < values.size(); ++i) {
          int prev = 0;
View Full Code Here


        BigInteger expected = BigInteger.valueOf(intMax);
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_SECOND));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_MINUTE));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_HOUR));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_DAY));
        expected = expected.divide(BigInteger.valueOf(DateTimeConstants.MILLIS_PER_WEEK));
        assertTrue(expected.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) < 0);
        assertEquals(expected.longValue(), test.toStandardWeeks().getWeeks());
       
        test = new Period(0, 0, Integer.MAX_VALUE, 7, 0, 0, 0, 0);
        try {
View Full Code Here

        long intMax = Integer.MAX_VALUE;
        BigInteger expected = BigInteger.valueOf(intMax);
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_SECOND));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_MINUTE));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_HOUR));
        expected = expected.divide(BigInteger.valueOf(DateTimeConstants.MILLIS_PER_DAY));
        assertTrue(expected.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) < 0);
        assertEquals(expected.longValue(), test.toStandardDays().getDays());
       
        test = new Period(0, 0, 0, Integer.MAX_VALUE, 24, 0, 0, 0);
        try {
View Full Code Here

        test = new Period(0, 0, 0, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
        long intMax = Integer.MAX_VALUE;
        BigInteger expected = BigInteger.valueOf(intMax);
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_SECOND));
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_MINUTE));
        expected = expected.divide(BigInteger.valueOf(DateTimeConstants.MILLIS_PER_HOUR));
        assertTrue(expected.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) < 0);
        assertEquals(expected.longValue(), test.toStandardHours().getHours());
       
        test = new Period(0, 0, 0, 0, Integer.MAX_VALUE, 60, 0, 0);
        try {
View Full Code Here

       
        test = new Period(0, 0, 0, 0, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
        long intMax = Integer.MAX_VALUE;
        BigInteger expected = BigInteger.valueOf(intMax);
        expected = expected.add(BigInteger.valueOf(intMax * DateTimeConstants.MILLIS_PER_SECOND));
        expected = expected.divide(BigInteger.valueOf(DateTimeConstants.MILLIS_PER_MINUTE));
        assertTrue(expected.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) < 0);
        assertEquals(expected.longValue(), test.toStandardMinutes().getMinutes());
       
        test = new Period(0, 0, 0, 0, 0, Integer.MAX_VALUE, 60, 0);
        try {
View Full Code Here

      if (b.signum() == -1)
        temp = temp.add(BigInteger.ONE).negate();
      temp = temp.add(a);
      if (temp.signum() == -1)
        temp = temp.subtract(c.subtract(BigInteger.ONE));
      return temp.divide(c);
    }
   
   
    public boolean equals(Object obj) {
      if (!(obj instanceof QuadraticSurd))
View Full Code Here

      Object nanosecondsObject) {
    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;
View Full Code Here

   
    BigInteger numer = BigInteger.ZERO;
    for (int i = TURNS / 2 + 1; i <= TURNS; i++)
      numer = numer.add(ways[TURNS][i]);
    BigInteger denom = Library.factorial(TURNS + 1);
    return denom.divide(numer).toString();
  }
 
}
View Full Code Here

      histogram[x]++;
   
    // Multinomial coefficient: BASE! / (histogram[0]! * histogram[1]! * ...)
    BigInteger ways = Library.factorial(BASE);
    for (int x : histogram)
      ways = ways.divide(Library.factorial(x));
   
    // Multinomial coefficient: LENGTH! / (freqs[0]! * freqs[1]! * ...)
    ways = ways.multiply(Library.factorial(LENGTH));
    for (int x : freqs)
      ways = ways.divide(Library.factorial(x));
View Full Code Here

      ways = ways.divide(Library.factorial(x));
   
    // Multinomial coefficient: LENGTH! / (freqs[0]! * freqs[1]! * ...)
    ways = ways.multiply(Library.factorial(LENGTH));
    for (int x : freqs)
      ways = ways.divide(Library.factorial(x));
   
    return ways;
  }
 
 
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.