Package java.math

Examples of java.math.BigInteger.divide()


            // Handle non-integral values or the case where parseBigDecimal is set
            else {
                BigDecimal big = digitList.getBigDecimalICU(status[STATUS_POSITIVE]);
                n = big;
                if (mult != 1) {
                    n = big.divide(BigDecimal.valueOf(mult), mathContext);
                }
            }
        }

        // Assemble into CurrencyAmount if necessary
View Full Code Here


                y >>= 1;
            }
           
            BigInteger bigX = BigInteger.valueOf(x);
            BigInteger bigXZ = bigX.multiply(bigX);
            if (bigXZ.divide(bigX).longValue() != z) {
                IRubyObject v = RubyBignum.newBignum(runtime, RubyBignum.fix2big(RubyFixnum.newFixnum(runtime, x))).op_pow(context, RubyFixnum.newFixnum(runtime, y));
                if (z != 1) v = RubyBignum.newBignum(runtime, RubyBignum.fix2big(RubyFixnum.newFixnum(runtime, neg ? -z : z))).op_mul19(context, v);
                return v;
            }
            z = bigXZ.longValue();
View Full Code Here

      assertTrue("a non-neg", a.signum() >= 0);

      BigInteger d = bi3.shiftRight(i);
      assertTrue("c==d", c.equals(d));
      c = c.shiftRight(1);
      assertTrue(">>1 == /2", d.divide(two).equals(c));
      assertTrue("c non-neg", c.signum() >= 0);

      BigInteger f = E.shiftRight(i);
      assertTrue("e==f", e.equals(f));
      e = e.shiftRight(1);
View Full Code Here

            // Handle non-integral values or the case where parseBigDecimal is set
            else {
                BigDecimal big = digitList.getBigDecimalICU(status[STATUS_POSITIVE]);
                n = big;
                if (mult != 1) {
                    n = big.divide(BigDecimal.valueOf(mult),
                            BigDecimal.ROUND_HALF_EVEN);
                }
            }
        }
View Full Code Here

            // Handle non-integral values or the case where parseBigDecimal is set
            else {
                BigDecimal big = digitList.getBigDecimalICU(status[STATUS_POSITIVE]);
                n = big;
                if (mult != 1) {
                    n = big.divide(BigDecimal.valueOf(mult), mathContext);
                }
            }
        }

        // Assemble into CurrencyAmount if necessary
View Full Code Here

  public double getAverage() {
    BigInteger sum = BigInteger.ZERO;
    for (long v : values) {
      sum.add(BigInteger.valueOf(v));
    }
    return sum.divide(BigInteger.valueOf(values.size())).doubleValue();
  }

}
View Full Code Here

      && (bi.compareTo(BigIntegerDecimal.MINLONG_MINUS_ONE) > 0))
      rangeOk = true;
     
    for (int i = 0; i < sqlScale; i++)
    {
      bi = bi.divide(BigIntegerDecimal.TEN);
      if (rangeOk)
        continue;
     
      if ((bi.compareTo(BigIntegerDecimal.MAXLONG_PLUS_ONE) < 0)
          && (bi.compareTo(BigIntegerDecimal.MINLONG_MINUS_ONE) > 0))
View Full Code Here

      rhs = exprAst.getChild(i);

      if (operator.equals("*")) {
        result = result.multiply(evalToInt(rhs));
      } else if (operator.equals("/")) {
        result = result.divide(evalToInt(rhs));
      } else if (operator.equals("%")) {
        result = result.mod(evalToInt(rhs));
      } else {
        throw new EvaluationException("Unknown multiplicative operator '" + operator + "'");
      }
View Full Code Here

      return BigInteger.valueOf(LongMath.binomial(n, k));
    }
    BigInteger result = BigInteger.ONE;
    for (int i = 0; i < k; i++) {
      result = result.multiply(BigInteger.valueOf(n - i));
      result = result.divide(BigInteger.valueOf(i + 1));
    }
    return result;
  }

  // Returns true if BigInteger.valueOf(x.longValue()).equals(x).
View Full Code Here

        if (values.size() == 1)
          return values.get(0);
        BigInteger total = BigInteger.valueOf(0);
        for (int i = 0; i < values.size(); ++i)
          total = total.add(BigInteger.valueOf(values.get(i)));
        return total.divide(BigInteger.valueOf(values.size())).longValue();
      case MEDIAN:
        if (values.size() % 2 == 1)
          return values.get(values.size() / 2);
        BigInteger bi = BigInteger.valueOf(values.get(
                values.size() / 2 - 1));
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.